From 3ac2d800d840f03618fc364090d786effde84b1f Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:13:16 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835142 13f79535-47bb-0310-9956-ffa450edef68 --- .../branches/sca-java-20080910/samples/README | 306 ++++++++++ .../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 | 29 + .../src/main/java/echo/EchoBindingFactory.java | 33 ++ .../java/echo/impl/EchoBindingFactoryImpl.java | 34 ++ .../src/main/java/echo/impl/EchoBindingImpl.java | 104 ++++ .../main/java/echo/impl/EchoBindingProcessor.java | 128 ++++ .../java/echo/provider/EchoBindingInvoker.java | 48 ++ .../echo/provider/EchoBindingPoliciedInvoker.java | 71 +++ .../echo/provider/EchoBindingProviderFactory.java | 58 ++ .../provider/EchoReferenceBindingProvider.java | 71 +++ .../echo/provider/EchoServiceBindingProvider.java | 78 +++ .../policy/EchoBindingEncryptionPolicy.java | 41 ++ .../EchoBindingEncryptionPolicyProcessor.java | 37 ++ .../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 | 54 ++ .../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 + ...any.sca.contribution.processor.ValidationSchema | 19 + ...che.tuscany.sca.provider.BindingProviderFactory | 19 + .../src/main/resources/sample-binding-echo.xsd | 36 ++ .../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 | 43 ++ .../src/test/resources/definitions.xml | 39 ++ .../sca-java-20080910/samples/binding-echo/README | 104 ++++ .../samples/binding-echo/binding-echo.png | Bin 0 -> 7846 bytes .../samples/binding-echo/binding-echo.svg | 174 ++++++ .../samples/binding-echo/build.xml | 75 +++ .../sca-java-20080910/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 | 110 ++++ .../binding-notification-broker.png | Bin 0 -> 36945 bytes .../samples/binding-notification-broker/build.xml | 75 +++ .../samples/binding-notification-broker/pom.xml | 97 +++ .../java/notification/broker/TestCaseProducer.java | 24 + .../java/notification/broker/TrafficAdvisory.java | 30 + .../broker/TrafficAdvisoryConsumer.java | 41 ++ .../broker/TrafficAdvisoryProducer.java | 36 ++ .../notification/broker/TrafficAdvisoryServer.java | 72 +++ .../TrafficAdvisoryNotification.componentType | 34 ++ .../TrafficAdvisoryNotification.composite | 61 ++ .../src/main/resources/wsdl/TrafficAdvisory.wsdl | 50 ++ .../samples/binding-notification-consumer/README | 102 ++++ .../binding-notification-consumer.png | Bin 0 -> 27279 bytes .../binding-notification-consumer/build.xml | 75 +++ .../samples/binding-notification-consumer/pom.xml | 115 ++++ .../notification/consumer/TrafficAdvisory.java | 30 + .../consumer/TrafficAdvisoryConsumer.java | 41 ++ .../consumer/TrafficAdvisoryServer.java | 48 ++ .../TrafficAdvisoryNotification.componentType | 34 ++ .../TrafficAdvisoryNotification.composite | 53 ++ .../src/main/resources/wsdl/TrafficAdvisory.wsdl | 50 ++ .../consumer/TrafficAdvisoryTestCase.java | 61 ++ .../samples/binding-notification-producer/README | 131 ++++ .../binding-notification-producer.png | Bin 0 -> 21631 bytes .../binding-notification-producer/build.xml | 75 +++ .../samples/binding-notification-producer/pom.xml | 126 ++++ .../notification/producer/TestCaseProducer.java | 24 + .../notification/producer/TrafficAdvisory.java | 30 + .../producer/TrafficAdvisoryProducer.java | 36 ++ .../producer/TrafficAdvisoryServer.java | 57 ++ .../TrafficAdvisoryNotification.componentType | 34 ++ .../TrafficAdvisoryNotification.composite | 44 ++ .../src/main/resources/wsdl/TrafficAdvisory.wsdl | 50 ++ .../producer/TrafficAdvisoryTestCase.java | 78 +++ .../samples/calculator-distributed/README | 438 ++++++++++++++ .../samples/calculator-distributed/build.xml | 111 ++++ .../calculator-distributed.png | Bin 0 -> 76839 bytes .../calculator-distributed.svg | 383 ++++++++++++ .../samples/calculator-distributed/cloud.composite | 26 + .../calculator-distributed/domain.composite | 26 + .../samples/calculator-distributed/pom.xml | 119 ++++ .../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/LaunchCalculatorNodeA.java | 67 +++ .../src/main/java/node/LaunchCalculatorNodeB.java | 28 + .../src/main/java/node/LaunchCalculatorNodeC.java | 28 + .../src/main/java/node/LaunchDomain.java | 33 ++ .../src/main/resources/cloud/NodeA.composite | 33 ++ .../src/main/resources/cloud/NodeB.composite | 33 ++ .../src/main/resources/cloud/NodeC.composite | 33 ++ .../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 | 29 + .../resources/nodeC/META-INF/sca-contribution.xml | 24 + .../calculator/CalculatorDistributedTestCase.java | 92 +++ .../samples/calculator-distributed/workspace.xml | 25 + .../calculator-implementation-policies/README | 266 +++++++++ .../calculator-implementation-policies/build.xml | 72 +++ .../calculator.png | Bin 0 -> 20552 bytes .../calculator.svg | 329 +++++++++++ .../calculator-implementation-policies/pom.xml | 78 +++ .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 35 ++ .../src/main/java/calculator/CalculatorClient.java | 66 +++ .../main/java/calculator/CalculatorService.java | 35 ++ .../java/calculator/CalculatorServiceImpl.java | 70 +++ .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 35 ++ .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 35 ++ .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 35 ++ .../security/CalculatorCallbackHandler.java | 50 ++ .../java/calculator/security/JaasLoginModule.java | 178 ++++++ .../java/calculator/security/UserPrincipal.java | 66 +++ .../src/main/resources/Calculator.composite | 61 ++ .../src/main/resources/CalculatorJass.config | 3 + .../resources/CalculatorLogMessages.properties | 18 + .../src/main/resources/definitions.xml | 40 ++ .../test/java/calculator/CalculatorTestCase.java | 74 +++ .../samples/calculator-lean/README | 87 +++ .../samples/calculator-lean/calculator.png | Bin 0 -> 20552 bytes .../samples/calculator-lean/calculator.svg | 329 +++++++++++ .../samples/calculator-lean/pom.xml | 71 +++ .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 35 ++ .../src/main/java/calculator/CalculatorClient.java | 51 ++ .../main/java/calculator/CalculatorService.java | 35 ++ .../java/calculator/CalculatorServiceImpl.java | 70 +++ .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 35 ++ .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 35 ++ .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 35 ++ .../src/main/resources/Calculator.composite | 54 ++ .../src/main/resources/CalculatorTest.composite | 32 + .../test/java/calculator/CalculatorTestCase.java | 62 ++ .../samples/calculator-osgi/README | 97 +++ .../samples/calculator-osgi/build.xml | 72 +++ .../samples/calculator-osgi/calculator.png | Bin 0 -> 20552 bytes .../samples/calculator-osgi/calculator.svg | 329 +++++++++++ .../samples/calculator-osgi/pom.xml | 99 ++++ .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 35 ++ .../src/main/java/calculator/CalculatorClient.java | 62 ++ .../main/java/calculator/CalculatorService.java | 35 ++ .../java/calculator/CalculatorServiceImpl.java | 70 +++ .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 35 ++ .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 35 ++ .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 35 ++ .../src/main/resources/Calculator.composite | 54 ++ .../test/java/calculator/CalculatorTestCase.java | 57 ++ .../samples/calculator-rcp/META-INF/MANIFEST.MF | 25 + .../samples/calculator-rcp/build.properties | 5 + .../samples/calculator-rcp/icons/alt_window_16.gif | Bin 0 -> 637 bytes .../samples/calculator-rcp/icons/alt_window_32.gif | Bin 0 -> 1192 bytes .../samples/calculator-rcp/plugin.xml | 31 + .../samples/calculator-rcp/pom.xml | 126 ++++ .../src/main/java/Calculator.composite | 54 ++ .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 35 ++ .../src/main/java/calculator/CalculatorClient.java | 52 ++ .../main/java/calculator/CalculatorService.java | 34 ++ .../java/calculator/CalculatorServiceImpl.java | 69 +++ .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 35 ++ .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 35 ++ .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 35 ++ .../src/main/java/calculator/rcp/Activator.java | 79 +++ .../src/main/java/calculator/rcp/Application.java | 63 ++ .../rcp/ApplicationActionBarAdvisor.java | 65 ++ .../rcp/ApplicationWorkbenchAdvisor.java | 37 ++ .../rcp/ApplicationWorkbenchWindowAdvisor.java | 44 ++ .../src/main/java/calculator/rcp/Perspective.java | 34 ++ .../src/main/java/calculator/rcp/View.java | 88 +++ .../samples/calculator-rmi-reference/README | 138 +++++ .../samples/calculator-rmi-reference/build.xml | 73 +++ .../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 ++ .../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/README | 118 ++++ .../samples/calculator-webapp/calculator-web.png | Bin 0 -> 22916 bytes .../samples/calculator-webapp/calculator-web.svg | 358 +++++++++++ .../samples/calculator-webapp/pom.xml | 95 +++ .../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 | 41 ++ .../calculator-webapp/src/main/webapp/calc.jsp | 47 ++ .../samples/calculator-ws-secure-webapp/README | 108 ++++ .../calculator-ws-secure-webapp/calculator-web.png | Bin 0 -> 25757 bytes .../calculator-ws-secure-webapp/calculator-web.svg | 455 ++++++++++++++ .../samples/calculator-ws-secure-webapp/pom.xml | 102 ++++ .../src/main/java/calculator/AddService.java | 31 + .../src/main/java/calculator/AddServiceImpl.java | 35 ++ .../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 | 31 + .../main/java/calculator/SubtractServiceImpl.java | 30 + .../calculator/security/ClientPWCBHandler.java | 58 ++ .../calculator/security/ServerPWCBHandler.java | 59 ++ .../src/main/resources/Calculator.composite | 67 +++ ...rg.apache.tuscany.sca.policy.util.PolicyHandler | 21 + .../src/main/resources/calculatorKeys.jks | Bin 0 -> 2706 bytes .../src/main/resources/definitions.xml | 198 +++++++ .../src/main/resources/security.properties | 4 + .../src/main/webapp/META-INF/sca-contribution.xml | 24 + .../src/main/webapp/WEB-INF/geronimo-web.xml | 33 ++ .../src/main/webapp/WEB-INF/web.xml | 41 ++ .../src/main/webapp/calc.jsp | 50 ++ .../samples/calculator-ws-webapp/README | 108 ++++ .../calculator-ws-webapp/calculator-web.png | Bin 0 -> 25757 bytes .../calculator-ws-webapp/calculator-web.svg | 455 ++++++++++++++ .../samples/calculator-ws-webapp/pom.xml | 102 ++++ .../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 | 56 ++ .../src/main/webapp/META-INF/sca-contribution.xml | 24 + .../src/main/webapp/WEB-INF/geronimo-web.xml | 34 ++ .../src/main/webapp/WEB-INF/web.xml | 41 ++ .../calculator-ws-webapp/src/main/webapp/calc.jsp | 50 ++ .../sca-java-20080910/samples/calculator/README | 97 +++ .../sca-java-20080910/samples/calculator/build.xml | 72 +++ .../samples/calculator/calculator.png | Bin 0 -> 20552 bytes .../samples/calculator/calculator.svg | 329 +++++++++++ .../sca-java-20080910/samples/calculator/pom.xml | 71 +++ .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 35 ++ .../src/main/java/calculator/CalculatorClient.java | 48 ++ .../main/java/calculator/CalculatorService.java | 35 ++ .../java/calculator/CalculatorServiceImpl.java | 70 +++ .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 35 ++ .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 35 ++ .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 35 ++ .../src/main/resources/Calculator.composite | 49 ++ .../test/java/calculator/CalculatorTestCase.java | 56 ++ .../sca-java-20080910/samples/calculator2/README | 97 +++ .../samples/calculator2/build.xml | 72 +++ .../samples/calculator2/calculator.png | Bin 0 -> 20552 bytes .../samples/calculator2/calculator.svg | 329 +++++++++++ .../sca-java-20080910/samples/calculator2/pom.xml | 65 ++ .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 35 ++ .../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 | 35 ++ .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 35 ++ .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 35 ++ .../src/main/resources/Calculator.composite | 49 ++ .../test/java/calculator/CalculatorTestCase.java | 51 ++ .../samples/callback-ws-client/README | 311 ++++++++++ .../samples/callback-ws-client/build.xml | 73 +++ .../callback-ws-client/callback-ws-client.png | Bin 0 -> 8812 bytes .../callback-ws-client/callback-ws-client.svg | 204 +++++++ .../samples/callback-ws-client/pom.xml | 86 +++ .../src/main/java/myapp/MyClient.java | 29 + .../src/main/java/myapp/MyClientImpl.java | 64 ++ .../src/main/java/myserver/MyService.java | 34 ++ .../src/main/java/myserver/MyServiceCallback.java | 30 + .../main/resources/META-INF/sca-contribution.xml | 22 + .../src/main/resources/myapp.composite | 36 ++ .../test/java/myapp/CallbackClientTestCase.java | 53 ++ .../samples/callback-ws-service/README | 227 +++++++ .../samples/callback-ws-service/build.xml | 73 +++ .../callback-ws-service/callback-ws-service.png | Bin 0 -> 8949 bytes .../callback-ws-service/callback-ws-service.svg | 200 +++++++ .../samples/callback-ws-service/pom.xml | 79 +++ .../src/main/java/myserver/CallbackServer.java | 48 ++ .../src/main/java/myserver/MyService.java | 34 ++ .../src/main/java/myserver/MyServiceCallback.java | 30 + .../src/main/java/myserver/MyServiceImpl.java | 56 ++ .../main/resources/META-INF/sca-contribution.xml | 24 + .../src/main/resources/callbackws.composite | 35 ++ .../test/java/myserver/CallbackServerTestCase.java | 52 ++ .../sca-java-20080910/samples/callbacks-jms/README | 73 +++ .../samples/callbacks-jms/build.xml | 72 +++ .../samples/callbacks-jms/pom.xml | 92 +++ .../src/main/java/callbacks/OrderCallback.java | 30 + .../src/main/java/callbacks/OrderRequest.java | 24 + .../src/main/java/callbacks/OrderResponse.java | 24 + .../src/main/java/callbacks/OrderService.java | 33 ++ .../main/java/callbacks/OrderServiceClient.java | 59 ++ .../src/main/java/callbacks/OrderServiceImpl.java | 51 ++ .../src/main/resources/callbacks.composite | 44 ++ .../src/main/resources/jndi.properties | 30 + .../src/test/java/callbacks/CallbacksTestCase.java | 64 ++ .../sca-java-20080910/samples/chat-webapp/README | 61 ++ .../samples/chat-webapp/chat-webapp.png | Bin 0 -> 6552 bytes .../samples/chat-webapp/chat-webapp.svg | 187 ++++++ .../sca-java-20080910/samples/chat-webapp/pom.xml | 97 +++ .../src/main/java/sample/ChatService.java | 26 + .../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 | 37 ++ .../samples/chat-webapp/src/main/webapp/chat.html | 70 +++ .../sca-java-20080910/samples/chat2-webapp/README | 61 ++ .../samples/chat2-webapp/build.xml | 117 ++++ .../sca-java-20080910/samples/chat2-webapp/pom.xml | 104 ++++ .../src/main/java/sample/ChatCallback.java | 27 + .../src/main/java/sample/ChatService.java | 32 + .../src/main/java/sample/ChatServiceImpl.java | 36 ++ .../chat2-webapp/src/main/resources/chat.composite | 40 ++ .../src/main/webapp/META-INF/sca-contribution.xml | 24 + .../chat2-webapp/src/main/webapp/WEB-INF/web.xml | 37 ++ .../samples/chat2-webapp/src/main/webapp/chat.html | 73 +++ .../sca-java-20080910/samples/customer-dojo/README | 104 ++++ .../samples/customer-dojo/build-dojo.xml | 92 +++ .../samples/customer-dojo/build.xml | 70 +++ .../customer-dojo/customer-dojo-jsonrpc.png | Bin 0 -> 9947 bytes .../customer-dojo/customer-dojo-jsonrpc.svg | 177 ++++++ .../samples/customer-dojo/customer.sql | 33 ++ .../samples/customer-dojo/pom.xml | 245 ++++++++ .../src/main/java/customer/Customer.java | 93 +++ .../src/main/java/customer/CustomerCollection.java | 26 + .../main/java/customer/CustomerCollectionImpl.java | 101 ++++ .../src/main/java/customer/CustomerService.java | 31 + .../main/java/customer/CustomerServiceImpl.java | 117 ++++ .../customer-dojo/src/main/java/launch/Launch.java | 34 ++ .../src/main/resources/META-INF/orm.xml | 51 ++ .../src/main/resources/META-INF/persistence.xml | 40 ++ .../main/resources/META-INF/sca-contribution.xml | 26 + .../src/main/resources/content/customer.html | 77 +++ .../src/main/resources/customer.composite | 44 ++ .../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 +++++++++++++ .../samples/databinding-echo/pom.xml | 82 +++ .../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 ++ .../samples/domain-management/README | 8 + .../samples/domain-management/pom.xml | 247 ++++++++ .../java/manager/DistributeAndRunComponents.java | 328 ++++++++++ .../main/java/manager/DistributeComponents.java | 288 +++++++++ .../src/main/java/manager/ListComponents.java | 158 +++++ .../src/main/java/manager/ListDependencies.java | 108 ++++ .../src/main/java/manager/ListDeployables.java | 73 +++ .../src/main/java/manager/WireComponents.java | 218 +++++++ .../src/test/java/services/Cart.java | 28 + .../src/test/java/services/Item.java | 66 +++ .../test/java/services/ShoppingCartClientImpl.java | 57 ++ .../src/test/java/services/ShoppingCartImpl.java | 100 ++++ .../src/test/resources/assembly/assets.xml | 38 ++ .../src/test/resources/assembly/client.xml | 34 ++ .../src/test/resources/assembly/store.xml | 34 ++ .../resources/assets/META-INF/sca-contribution.xml | 22 + .../resources/client/META-INF/sca-contribution.xml | 24 + .../src/test/resources/client/client.composite | 35 ++ .../resources/store/META-INF/sca-contribution.xml | 24 + .../src/test/resources/store/store.composite | 32 + .../sca-java-20080910/samples/domain-webapp/README | 310 ++++++++++ .../samples/domain-webapp/build.xml | 296 +++++++++ .../samples/domain-webapp/pom.xml | 101 ++++ .../src/main/java/node/DomainServer.java | 54 ++ .../main/resources/META-INF/sca-contribution.xml | 24 + .../src/main/resources/domain.composite | 54 ++ .../src/main/resources/webroot/index.html | 354 +++++++++++ .../src/main/resources/webroot/node.png | Bin 0 -> 689 bytes .../src/main/resources/webroot/style.css | 176 ++++++ .../samples/feed-aggregator-webapp/README | 55 ++ .../feed-aggregator-webapp.png | Bin 0 -> 23443 bytes .../feed-aggregator-webapp.svg | 382 ++++++++++++ .../samples/feed-aggregator-webapp/pom.xml | 108 ++++ .../src/main/java/feed/AggregatorImpl.java | 178 ++++++ .../src/main/java/feed/Sort.java | 38 ++ .../src/main/java/feed/SortImpl.java | 57 ++ .../src/main/resources/FeedAggregator.composite | 60 ++ .../src/main/webapp/META-INF/sca-contribution.xml | 26 + .../src/main/webapp/WEB-INF/web.xml | 41 ++ .../src/main/webapp/index.html | 32 + .../samples/feed-aggregator/README | 110 ++++ .../samples/feed-aggregator/build.xml | 72 +++ .../samples/feed-aggregator/feed-aggregator.png | Bin 0 -> 17429 bytes .../samples/feed-aggregator/feed-aggregator.svg | 364 ++++++++++++ .../samples/feed-aggregator/pom.xml | 84 +++ .../src/main/java/feed/AggregatorImpl.java | 188 ++++++ .../feed-aggregator/src/main/java/feed/Sort.java | 38 ++ .../src/main/java/feed/SortImpl.java | 57 ++ .../src/main/java/launch/LaunchFeedServer.java | 47 ++ .../src/main/resources/FeedAggregator.composite | 60 ++ .../src/test/java/feed/FeedAggregatorTest.java | 332 +++++++++++ .../samples/helloworld-bpel-ws/README | 151 +++++ .../samples/helloworld-bpel-ws/build.xml | 95 +++ .../samples/helloworld-bpel-ws/helloworld-bpel.png | Bin 0 -> 8897 bytes .../samples/helloworld-bpel-ws/helloworld-bpel.svg | 179 ++++++ .../samples/helloworld-bpel-ws/pom.xml | 205 +++++++ .../src/main/java/helloworld/BPELClient.java | 43 ++ .../src/main/resources/deploy.xml | 31 + .../src/main/resources/helloworld.bpel | 66 +++ .../src/main/resources/helloworld.componentType | 30 + .../src/main/resources/helloworld.composite | 33 ++ .../src/main/resources/helloworld.wsdl | 82 +++ .../src/main/resources/log4j.properties | 35 ++ .../java/helloworld/BPELHelloWorldTestCase.java | 59 ++ .../samples/helloworld-bpel/README | 151 +++++ .../samples/helloworld-bpel/build.xml | 95 +++ .../samples/helloworld-bpel/helloworld-bpel.png | Bin 0 -> 8897 bytes .../samples/helloworld-bpel/helloworld-bpel.svg | 179 ++++++ .../samples/helloworld-bpel/pom.xml | 198 +++++++ .../src/main/java/helloworld/BPELClient.java | 43 ++ .../helloworld-bpel/src/main/resources/deploy.xml | 31 + .../src/main/resources/helloworld.bpel | 66 +++ .../src/main/resources/helloworld.componentType | 30 + .../src/main/resources/helloworld.composite | 29 + .../src/main/resources/helloworld.wsdl | 82 +++ .../src/main/resources/log4j.properties | 35 ++ .../java/helloworld/BPELHelloWorldTestCase.java | 59 ++ .../samples/helloworld-distributed/README | 28 + .../helloworld-distributed/helloworld-node/README | 28 + .../helloworld-distributed/helloworld-node/pom.xml | 71 +++ .../src/main/java/sample/Helloworld.java | 29 + .../src/main/java/sample/HelloworldImpl.java | 29 + .../src/main/java/sample/HelloworldNode.java | 40 ++ .../src/main/resources/Helloworld.composite | 28 + .../helloworld-webapp/README | 28 + .../helloworld-webapp/build.xml | 128 ++++ .../helloworld-webapp/pom.xml | 72 +++ .../src/main/java/sample/Helloworld.java | 27 + .../src/main/webapp/WEB-INF/web.composite | 29 + .../src/main/webapp/WEB-INF/web.xml | 41 ++ .../helloworld-webapp/src/main/webapp/hello.jsp | 36 ++ .../samples/helloworld-dojo-webapp/README | 104 ++++ .../samples/helloworld-dojo-webapp/build-dojo.xml | 92 +++ .../samples/helloworld-dojo-webapp/build.xml | 70 +++ .../helloworld-dojo-webapp/helloworld-jsonrpc.png | Bin 0 -> 9947 bytes .../helloworld-dojo-webapp/helloworld-jsonrpc.svg | 177 ++++++ .../samples/helloworld-dojo-webapp/pom.xml | 163 +++++ .../java/helloworldjsonrpc/HelloWorldService.java | 28 + .../helloworldjsonrpc/HelloWorldServiceImpl.java | 38 ++ .../src/main/resources/jsonrpc.composite | 37 ++ .../src/main/webapp/HelloWorldJSONRPC.html | 98 +++ .../src/main/webapp/META-INF/sca-contribution.xml | 26 + .../src/main/webapp/WEB-INF/web.xml | 41 ++ .../src/main/webapp/style.css | 22 + .../samples/helloworld-jms-webapp/README | 130 ++++ .../samples/helloworld-jms-webapp/pom.xml | 72 +++ .../src/main/java/helloworld/HelloWorldClient.java | 37 ++ .../main/java/helloworld/HelloWorldService.java | 29 + .../java/helloworld/HelloWorldServiceImpl.java | 34 ++ .../src/main/webapp/META-INF/context.xml | 29 + .../META-INF/sca-deployables/HelloWorld.composite | 39 ++ .../src/main/webapp/WEB-INF/web.xml | 66 +++ .../src/main/webapp/hello.jsp | 44 ++ .../samples/helloworld-jsonrpc-webapp/README | 90 +++ .../helloworld-jsonrpc.png | Bin 0 -> 9947 bytes .../helloworld-jsonrpc.svg | 177 ++++++ .../samples/helloworld-jsonrpc-webapp/pom.xml | 103 ++++ .../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 | 41 ++ .../src/main/webapp/style.css | 22 + .../samples/helloworld-jsp/pom.xml | 54 ++ .../src/main/java/sample/HelloworldService.java | 7 + .../main/java/sample/HelloworldServiceImpl.java | 12 + .../webapp/META-INF/sca-deployables/web.composite | 34 ++ .../helloworld-jsp/src/main/webapp/WEB-INF/web.xml | 42 ++ .../helloworld-jsp/src/main/webapp/hello.jsp | 36 ++ .../samples/helloworld-reference-jms/README | 114 ++++ .../samples/helloworld-reference-jms/build.xml | 72 +++ .../helloworld-reference.png | Bin 0 -> 12973 bytes .../helloworld-reference.svg | 144 +++++ .../samples/helloworld-reference-jms/pom.xml | 92 +++ .../src/main/java/helloworld/HelloWorldImpl.java | 33 ++ .../main/java/helloworld/HelloWorldJmsClient.java | 41 ++ .../main/java/helloworld/HelloWorldService.java | 29 + .../helloworld/HelloWorldServiceComponent.java | 42 ++ .../resources/helloworldjmsreference.composite | 40 ++ .../main/resources/helloworldjmsservice.composite | 39 ++ .../src/main/resources/logging.properties | 30 + .../src/main/resources/wsdl/helloworld.wsdl | 92 +++ .../helloworld/HelloWorldJmsClientTestCase.java | 80 +++ .../samples/helloworld-service-jms/README | 101 ++++ .../samples/helloworld-service-jms/build.xml | 72 +++ .../helloworld-service-jms/helloworld-service.png | Bin 0 -> 9455 bytes .../helloworld-service-jms/helloworld-service.svg | 139 +++++ .../samples/helloworld-service-jms/pom.xml | 85 +++ .../src/main/java/helloworld/HelloWorldImpl.java | 33 ++ .../src/main/java/helloworld/HelloWorldServer.java | 58 ++ .../main/java/helloworld/HelloWorldService.java | 31 + .../src/main/resources/definitions.xml | 66 +++ .../main/resources/helloworldjmsservice.composite | 40 ++ .../src/main/resources/wsdl/helloworld.wsdl | 92 +++ .../helloworld/HelloWorldJmsServerTestCaseOff.java | 60 ++ .../samples/helloworld-servlet/pom.xml | 61 ++ .../src/main/java/sample/HelloworldService.java | 7 + .../main/java/sample/HelloworldServiceImpl.java | 12 + .../src/main/java/sample/HelloworldServlet.java | 65 ++ .../webapp/META-INF/sca-deployables/web.composite | 33 ++ .../src/main/webapp/WEB-INF/web.xml | 52 ++ .../helloworld-servlet/src/main/webapp/hello.html | 46 ++ .../samples/helloworld-web-callback/pom.xml | 68 +++ .../src/main/java/sample/HelloworldCallback.java | 30 + .../src/main/java/sample/HelloworldService.java | 14 + .../main/java/sample/HelloworldServiceImpl.java | 27 + .../webapp/META-INF/sca-deployables/web.composite | 45 ++ .../src/main/webapp/WEB-INF/web.xml | 42 ++ .../src/main/webapp/hello.html | 63 ++ .../samples/helloworld-web/pom.xml | 68 +++ .../src/main/java/sample/HelloworldService.java | 7 + .../main/java/sample/HelloworldServiceImpl.java | 12 + .../webapp/META-INF/sca-deployables/web.composite | 39 ++ .../helloworld-web/src/main/webapp/WEB-INF/web.xml | 42 ++ .../helloworld-web/src/main/webapp/hello.html | 62 ++ .../samples/helloworld-ws-deep-webapp/README | 1 + .../samples/helloworld-ws-deep-webapp/build.xml | 158 +++++ .../samples/helloworld-ws-deep-webapp/pom.xml | 45 ++ .../src/main/java/helloworld/HelloWorldImpl.java | 33 ++ .../main/java/helloworld/HelloWorldService.java | 30 + .../sca-deployables/helloworldws.composite | 32 + .../src/main/resources/wsdl/helloworld.wsdl | 79 +++ .../src/main/webapp/WEB-INF/web.xml | 27 + .../samples/helloworld-ws-reference-jms/README | 127 ++++ .../samples/helloworld-ws-reference-jms/build.xml | 72 +++ .../helloworld-ws-reference.png | Bin 0 -> 7549 bytes .../helloworld-ws-reference.svg | 150 +++++ .../samples/helloworld-ws-reference-jms/pom.xml | 92 +++ .../src/main/java/helloworld/HelloWorldImpl.java | 33 ++ .../main/java/helloworld/HelloWorldJmsClient.java | 38 ++ .../main/java/helloworld/HelloWorldService.java | 29 + .../helloworld/HelloWorldServiceComponent.java | 42 ++ .../src/main/resources/helloworldwsjms.composite | 34 ++ .../main/resources/helloworldwsjmsclient.composite | 45 ++ .../src/main/resources/logging.properties | 30 + .../src/main/resources/wsdl/helloworld.wsdl | 92 +++ .../helloworld/HelloWorldJmsClientTestCase.java | 84 +++ .../samples/helloworld-ws-reference-lean/README | 178 ++++++ .../helloworld-ws-reference.png | Bin 0 -> 7549 bytes .../helloworld-ws-reference.svg | 150 +++++ .../samples/helloworld-ws-reference-lean/pom.xml | 79 +++ .../src/main/java/helloworld/HelloWorldClient.java | 47 ++ .../main/java/helloworld/HelloWorldClient2.java | 53 ++ .../main/java/helloworld/HelloWorldClient3.java | 47 ++ .../main/java/helloworld/HelloWorldClient4.java | 52 ++ .../main/java/helloworld/HelloWorldClient5.java | 47 ++ .../main/java/helloworld/HelloWorldService.java | 29 + .../main/resources/helloworldwsclient.composite | 33 ++ .../main/resources/helloworldwsclient2.composite | 33 ++ .../main/resources/helloworldwsclient3.composite | 33 ++ .../main/resources/helloworldwsclient4.composite | 34 ++ .../main/resources/helloworldwsclient5.composite | 33 ++ .../src/main/resources/logging.properties | 30 + .../src/main/resources/wsdl/helloworld.wsdl | 92 +++ .../java/helloworld/HelloWorldClientTestCase.java | 58 ++ .../test/java/helloworld/HelloWorldTestServer.java | 55 ++ .../samples/helloworld-ws-reference-secure/README | 176 ++++++ .../helloworld-ws-reference-secure/build.xml | 72 +++ .../helloworld-ws-reference-secure.png | Bin 0 -> 7549 bytes .../helloworld-ws-reference-secure.svg | 150 +++++ .../samples/helloworld-ws-reference-secure/pom.xml | 85 +++ .../main/java/helloworld/ClientPWCBHandler.java | 45 ++ .../src/main/java/helloworld/HelloWorldClient.java | 42 ++ .../main/java/helloworld/HelloWorldService.java | 29 + .../helloworld/HelloWorldServiceComponent.java | 42 ++ ...rg.apache.tuscany.sca.policy.util.PolicyHandler | 21 + .../src/main/resources/definitions.xml | 203 +++++++ .../src/main/resources/helloworldKeys.jks | Bin 0 -> 1366 bytes .../main/resources/helloworldwsclient.composite | 58 ++ .../src/main/resources/logging.properties | 30 + .../src/main/resources/wsdl/helloworld.wsdl | 85 +++ .../java/helloworld/HelloWorldClientTestCase.java | 74 +++ .../test/java/helloworld/HelloWorldTestServer.java | 55 ++ .../samples/helloworld-ws-reference/README | 178 ++++++ .../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 | 29 + .../helloworld/HelloWorldServiceComponent.java | 42 ++ .../main/resources/helloworldwsclient.composite | 45 ++ .../src/main/resources/logging.properties | 30 + .../src/main/resources/wsdl/helloworld.wsdl | 92 +++ .../java/helloworld/HelloWorldClientTestCase.java | 74 +++ .../test/java/helloworld/HelloWorldTestServer.java | 55 ++ .../samples/helloworld-ws-sdo-webapp/README | 92 +++ .../samples/helloworld-ws-sdo-webapp/build.xml | 99 ++++ .../helloworld-ws-sdo-webapp.png | Bin 0 -> 12242 bytes .../helloworld-ws-sdo-webapp.svg | 221 +++++++ .../samples/helloworld-ws-sdo-webapp/pom.xml | 200 +++++++ .../src/main/java/helloworld/HelloWorld.java | 44 ++ .../main/java/helloworld/HelloWorldComponent.java | 40 ++ .../src/main/java/helloworld/HelloWorldImpl.java | 48 ++ .../src/main/resources/helloworldws.composite | 43 ++ .../src/main/resources/wsdl/helloworld.wsdl | 111 ++++ .../src/main/resources/wsdl/helloworld.xsd | 30 + .../src/main/webapp/HelloWorld.jsp | 48 ++ .../src/main/webapp/META-INF/sca-contribution.xml | 24 + .../src/main/webapp/WEB-INF/geronimo-web.xml | 41 ++ .../src/main/webapp/WEB-INF/web.xml | 46 ++ .../samples/helloworld-ws-sdo/README | 214 +++++++ .../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 | 29 + .../helloworld/HelloWorldServiceComponent.java | 42 ++ .../src/main/resources/helloworldws.composite | 32 + .../main/resources/helloworldwsclient.composite | 33 ++ .../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-jms/README | 119 ++++ .../samples/helloworld-ws-service-jms/build.xml | 72 +++ .../helloworld-ws-service.png | Bin 0 -> 6531 bytes .../helloworld-ws-service.svg | 150 +++++ .../samples/helloworld-ws-service-jms/pom.xml | 87 +++ .../src/main/java/helloworld/HelloWorldImpl.java | 33 ++ .../src/main/java/helloworld/HelloWorldServer.java | 60 ++ .../main/java/helloworld/HelloWorldService.java | 31 + .../src/main/resources/definitions.xml | 66 +++ .../src/main/resources/helloworldwsjms.composite | 35 ++ .../main/resources/helloworldwsjmspolicy.composite | 34 ++ .../src/main/resources/wsdl/helloworld.wsdl | 92 +++ .../HelloWorldJmsPolicyServerTestCase.java | 68 +++ .../helloworld/HelloWorldJmsServerTestCase.java | 72 +++ .../samples/helloworld-ws-service-secure/README | 152 +++++ .../samples/helloworld-ws-service-secure/build.xml | 72 +++ .../helloworld-ws-service-secure.png | Bin 0 -> 158 bytes .../helloworld-ws-service-secure.svg | 149 +++++ .../samples/helloworld-ws-service-secure/pom.xml | 85 +++ .../src/main/java/helloworld/HelloWorldImpl.java | 33 ++ .../src/main/java/helloworld/HelloWorldServer.java | 46 ++ .../main/java/helloworld/HelloWorldService.java | 31 + .../main/java/helloworld/ServerPWCBHandler.java | 55 ++ .../src/main/resources/definitions.xml | 113 ++++ .../src/main/resources/helloworldKeys.jks | Bin 0 -> 1366 bytes .../src/main/resources/helloworldws.composite | 41 ++ .../src/main/resources/wsdl/helloworld.wsdl | 79 +++ .../java/helloworld/HelloWorldServerTestCase.java | 62 ++ .../samples/helloworld-ws-service-webapp/README | 1 + .../samples/helloworld-ws-service-webapp/build.xml | 156 +++++ .../samples/helloworld-ws-service-webapp/pom.xml | 80 +++ .../src/main/java/helloworld/HelloWorldImpl.java | 33 ++ .../main/java/helloworld/HelloWorldService.java | 30 + .../src/main/resources/wsdl/helloworld.wsdl | 79 +++ .../sca-deployables/helloworldws.composite | 32 + .../src/main/webapp/WEB-INF/geronimo-web.xml | 33 ++ .../src/main/webapp/WEB-INF/web.xml | 45 ++ .../samples/helloworld-ws-service/README | 141 +++++ .../samples/helloworld-ws-service/build.xml | 72 +++ .../helloworld-ws-service.png | Bin 0 -> 6531 bytes .../helloworld-ws-service.svg | 150 +++++ .../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 | 31 + .../sca-deployables/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 | 72 +++ .../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 | 50 ++ .../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 | 79 +++ .../crud/provider/CRUDImplementationProvider.java | 75 +++ .../CRUDImplementationProviderFactory.java | 51 ++ .../services/crud.CRUDImplementationFactory | 19 + ...ca.contribution.processor.StAXArtifactProcessor | 19 + ...any.sca.contribution.processor.ValidationSchema | 19 + ...cany.sca.provider.ImplementationProviderFactory | 19 + .../main/resources/sample-implementation-crud.xsd | 38 ++ .../src/test/java/crud/CRUDTestCase.java | 60 ++ .../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 | 59 ++ .../src/main/resources/crud.composite | 30 + .../src/test/java/crud/client/CRUDTestCase.java | 61 ++ .../samples/implementation-notification/README | 93 +++ .../samples/implementation-notification/build.xml | 72 +++ .../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/TrafficAdvisoryClient.java | 45 ++ .../java/notification/TrafficAdvisoryConsumer.java | 39 ++ .../java/notification/TrafficAdvisoryProducer.java | 36 ++ .../TrafficAdvisoryNotification.componentType | 30 + .../TrafficAdvisoryNotification.composite | 50 ++ .../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 | 155 +++++ .../pojo/impl/POJOImplementationProcessor.java | 174 ++++++ .../pojo/provider/POJOImplementationInvoker.java | 68 +++ .../pojo/provider/POJOImplementationProvider.java | 106 ++++ .../POJOImplementationProviderFactory.java | 45 ++ ...ca.contribution.processor.StAXArtifactProcessor | 19 + ...any.sca.contribution.processor.ValidationSchema | 19 + ...cany.sca.provider.ImplementationProviderFactory | 19 + .../services/pojo.POJOImplementationFactory | 19 + .../main/resources/sample-implementation-pojo.xsd | 38 ++ .../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 | 51 ++ .../helloworld/HelloWorldImpl2.componentType | 26 + .../test/resources/helloworld/helloworld.composite | 33 ++ .../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/osgi-supplychain/README | 161 +++++ .../samples/osgi-supplychain/build-bundles.xml | 32 + .../samples/osgi-supplychain/build.xml | 128 ++++ .../samples/osgi-supplychain/osgi-supplychain.png | Bin 0 -> 13558 bytes .../samples/osgi-supplychain/osgi-supplychain.svg | 272 +++++++++ .../samples/osgi-supplychain/pom.xml | 187 ++++++ .../src/main/java/supplychain/OSGiBundleImpl.java | 121 ++++ .../main/java/supplychain/SupplyChainClient.java | 43 ++ .../main/java/supplychain/customer/Customer.java | 33 ++ .../customer/JavaCustomerComponentImpl.java | 50 ++ .../customer/OSGiCustomerComponentImpl.java | 51 ++ .../supplychain/customer/OSGiCustomerImpl.java | 47 ++ .../retailer/JavaRetailerComponentImpl.java | 53 ++ .../retailer/OSGiRetailerComponentImpl.java | 46 ++ .../supplychain/retailer/OSGiRetailerImpl.java | 44 ++ .../main/java/supplychain/retailer/Retailer.java | 28 + .../shipper/JavaShipperComponentImpl.java | 47 ++ .../shipper/OSGiShipperComponentImpl.java | 45 ++ .../java/supplychain/shipper/OSGiShipperImpl.java | 42 ++ .../src/main/java/supplychain/shipper/Shipper.java | 28 + .../warehouse/JavaWarehouseComponentImpl.java | 47 ++ .../warehouse/OSGiWarehouseComponentImpl.java | 47 ++ .../supplychain/warehouse/OSGiWarehouseImpl.java | 44 ++ .../main/java/supplychain/warehouse/Warehouse.java | 28 + .../src/main/resources/Customer.componentType | 28 + .../src/main/resources/DSCustomer.componentType | 28 + .../src/main/resources/DSRetailer.componentType | 28 + .../src/main/resources/DSShipper.componentType | 28 + .../src/main/resources/DSWarehouse.componentType | 28 + .../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 | 32 + .../src/main/resources/osgi/ds/Retailer.mf | 11 + .../src/main/resources/osgi/ds/Retailer.xml | 32 + .../src/main/resources/osgi/ds/Shipper.mf | 10 + .../src/main/resources/osgi/ds/Shipper.xml | 33 ++ .../src/main/resources/osgi/ds/Warehouse.mf | 11 + .../src/main/resources/osgi/ds/Warehouse.xml | 32 + .../src/main/resources/supplychain.composite | 61 ++ .../src/main/resources/supplychain.ds.composite | 61 ++ .../supplychain/SupplyChainClientTestCase.java | 60 ++ .../sca-java-20080910/samples/photo-gallery/README | 28 + .../samples/photo-gallery/build.xml | 79 +++ .../samples/photo-gallery/photo-gallery.png | Bin 0 -> 15670 bytes .../samples/photo-gallery/photo-gallery.svg | 304 ++++++++++ .../samples/photo-gallery/pom.xml | 148 +++++ .../src/main/java/launch/LaunchGallery.java | 34 ++ .../src/main/java/launch/LaunchGalleryJCR.java | 34 ++ .../src/main/java/services/Album.java | 29 + .../src/main/java/services/AlbumImpl.java | 95 +++ .../src/main/java/services/jcr/AlbumImpl.java | 159 +++++ .../photo-gallery/src/main/resources/gallery.html | 135 +++++ .../src/main/resources/gallery/boston/dsc00368.jpg | Bin 0 -> 32808 bytes .../src/main/resources/gallery/boston/dsc00369.jpg | Bin 0 -> 35980 bytes .../src/main/resources/gallery/boston/dsc00370.jpg | Bin 0 -> 44614 bytes .../src/main/resources/gallery/boston/dsc00371.jpg | Bin 0 -> 40745 bytes .../src/main/resources/gallery/boston/dsc00373.jpg | Bin 0 -> 76470 bytes .../src/main/resources/gallery/boston/dsc00375.jpg | Bin 0 -> 34834 bytes .../src/main/resources/gallery/boston/dsc00376.jpg | Bin 0 -> 38797 bytes .../src/main/resources/gallery/boston/dsc00377.jpg | Bin 0 -> 35776 bytes .../src/main/resources/gallery/boston/dsc00378.jpg | Bin 0 -> 35248 bytes .../src/main/resources/gallery/boston/dsc00379.jpg | Bin 0 -> 55042 bytes .../src/main/resources/gallery/boston/dsc00380.jpg | Bin 0 -> 55236 bytes .../photo-gallery/src/main/resources/index.gif | Bin 0 -> 564 bytes .../photo-gallery/src/main/resources/index_on.gif | Bin 0 -> 577 bytes .../photo-gallery/src/main/resources/next.gif | Bin 0 -> 535 bytes .../src/main/resources/next_disabled.gif | Bin 0 -> 536 bytes .../photo-gallery/src/main/resources/next_on.gif | Bin 0 -> 542 bytes .../src/main/resources/photo-gallery-jcr.composite | 47 ++ .../src/main/resources/photo-gallery.composite | 47 ++ .../photo-gallery/src/main/resources/prev.gif | Bin 0 -> 534 bytes .../src/main/resources/prev_disabled.gif | Bin 0 -> 536 bytes .../photo-gallery/src/main/resources/prev_on.gif | Bin 0 -> 541 bytes .../src/main/resources/show_slide.gif | Bin 0 -> 533 bytes .../photo-gallery/src/main/resources/space.gif | Bin 0 -> 116 bytes .../photo-gallery/src/main/resources/styles.css | 121 ++++ .../branches/sca-java-20080910/samples/pom.xml | 110 ++++ .../sca-java-20080910/samples/quote-xquery/README | 450 ++++++++++++++ .../samples/quote-xquery/build.xml | 120 ++++ .../sca-java-20080910/samples/quote-xquery/pom.xml | 184 ++++++ .../java/xquery/quote/AvailQuoteProviderImpl.java | 30 + .../xquery/quote/AvailQuoteProviderNodeInfo.java | 28 + .../xquery/quote/AvailQuoteProviderService.java | 27 + .../xquery/quote/ExternalReferencesQuoteJoin.java | 27 + .../main/java/xquery/quote/PriceQuoteProvider.java | 28 + .../java/xquery/quote/PriceQuoteProviderImpl.java | 27 + .../xquery/quote/PriceQuoteProviderNodeInfo.java | 28 + .../java/xquery/quote/PropertiesQuoteJoin.java | 32 + .../main/java/xquery/quote/QuoteCalculator.java | 26 + .../java/xquery/quote/QuoteCalculatorImpl.java | 38 ++ .../src/main/java/xquery/quote/QuoteDataUtil.java | 107 ++++ .../src/main/java/xquery/quote/QuoteJoin.java | 34 ++ .../src/main/java/xquery/quote/QuoteJoinLocal.java | 34 ++ .../main/java/xquery/quote/QuoteJoinLocalImpl.java | 67 +++ .../main/java/xquery/quote/XQueryQuoteClient.java | 145 +++++ .../main/java/xquery/quote/XQueryQuoteServer.java | 39 ++ .../src/main/resources/META-INF/sca/quote_join.xq | 61 ++ .../META-INF/sca/quote_join_external_references.xq | 69 +++ .../META-INF/sca/quote_join_properties.xq | 74 +++ .../src/main/resources/wsdl/AvailQuote.xsd | 39 ++ .../src/main/resources/wsdl/PriceQuote.xsd | 49 ++ .../quote-xquery/src/main/resources/wsdl/Quote.xsd | 40 ++ .../src/main/resources/wsdl/quotejoin.wsdl | 137 +++++ .../src/main/resources/xqueryquotews.composite | 55 ++ .../main/resources/xqueryquotewsclient.composite | 113 ++++ .../xquery/quote/XQueryQuoteClientTestCase.java | 192 ++++++ .../java/xquery/quote/XQueryQuoteTestServer.java | 50 ++ .../samples/simple-bigbank-spring/README | 148 +++++ .../samples/simple-bigbank-spring/build-dojo.xml | 92 +++ .../samples/simple-bigbank-spring/build.xml | 72 +++ .../samples/simple-bigbank-spring/pom.xml | 252 ++++++++ .../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 | 145 +++++ .../account/checking/CheckingAccountDetails.java | 45 ++ .../account/checking/CheckingAccountService.java | 34 ++ .../java/bigbank/account/feed/AccountFeedImpl.java | 71 +++ .../account/savings/SavingsAccountDetails.java | 47 ++ .../account/savings/SavingsAccountService.java | 32 + .../account/savings/SavingsAccountServiceImpl.java | 62 ++ .../bigbank/account/stock/StockAccountDetails.java | 63 ++ .../bigbank/account/stock/StockAccountService.java | 33 ++ .../account/stock/StockAccountServiceImpl.java | 56 ++ .../java/bigbank/calculator/CalculatorService.java | 34 ++ .../main/java/bigbank/client/BigBankClient.java | 46 ++ .../main/java/bigbank/server/BigBankServer.java | 54 ++ .../java/bigbank/stockquote/StockQuoteService.java | 31 + .../src/main/resources/BigBank.composite | 88 +++ .../src/main/resources/SavingsAccount.composite | 32 + .../src/main/resources/StockAccount.composite | 32 + .../spring-context/Account-spring-context.xml | 53 ++ .../spring-context/SavingsAccount-context.xml | 33 ++ .../StockAccount/META-INF/MANIFEST.MF | 4 + .../META-INF/spring/StockAccount-context.xml | 33 ++ .../src/main/resources/web/style.css | 22 + .../src/test/java/bigbank/BigBankTestCase.java | 34 ++ .../samples/simple-bigbank/README | 101 ++++ .../samples/simple-bigbank/build.xml | 72 +++ .../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 | 144 +++++ .../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 | 109 ++++ .../simplecallback/SimpleCallbackTestCase.java | 53 ++ .../samples/simple-callback/README | 97 +++ .../samples/simple-callback/build.xml | 72 +++ .../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 + .../samples/spring-bigbank-calculator/README | 2 + .../samples/spring-bigbank-calculator/build.xml | 72 +++ .../samples/spring-bigbank-calculator/pom.xml | 92 +++ .../main/java/bigbank/calculator/AddService.java | 25 + .../java/bigbank/calculator/CalculatorService.java | 34 ++ .../bigbank/calculator/CalculatorServiceImpl.java | 72 +++ .../java/bigbank/calculator/DivideService.java | 25 + .../java/bigbank/calculator/MultiplyService.java | 25 + .../java/bigbank/calculator/SubtractService.java | 25 + .../calculator/server/CalculatorServer.java | 44 ++ .../src/main/resources/Calculator.composite | 56 ++ .../META-INF/spring/CalculatorService-context.xml | 45 ++ .../main/resources/calculator/AddServiceImpl.js | 22 + .../resources/calculator/DivideServiceImpl.groovy | 22 + .../resources/calculator/MultiplyServiceImpl.py | 21 + .../resources/calculator/SubtractServiceImpl.rb | 22 + .../samples/spring-bigbank-checkaccount/README | 4 + .../samples/spring-bigbank-checkaccount/build.xml | 73 +++ .../samples/spring-bigbank-checkaccount/pom.xml | 108 ++++ .../account/checking/CheckingAccountDetails.java | 50 ++ .../account/checking/CheckingAccountService.java | 37 ++ .../checking/CheckingAccountServiceImpl.java | 66 +++ .../checking/server/CheckingAccountServer.java | 61 ++ .../AccountsDataPasswordCallbackHandler.java | 54 ++ .../account/security/BigbankCheckingsAcl.java | 48 ++ ...ckingsDeptAuthImplementationPolicyProvider.java | 90 +++ .../account/security/CheckingsDeptAuthPolicy.java | 46 ++ .../CheckingsDeptAuthPolicyInterceptor.java | 71 +++ .../CheckingsDeptAuthPolicyProviderFactory.java | 75 +++ .../CheckingsDeptAuthorizationPolicyHandler.java | 65 ++ .../CheckingsDeptAuthorizationPolicyProcessor.java | 72 +++ .../src/main/resources/CheckingsAccount.composite | 41 ++ ...ca.contribution.processor.StAXArtifactProcessor | 19 + ...rg.apache.tuscany.sca.policy.util.PolicyHandler | 20 + ...ache.tuscany.sca.provider.PolicyProviderFactory | 19 + .../src/main/resources/definitions.xml | 58 ++ .../spring/CheckingAccountService-context.xml | 33 ++ .../samples/spring-bigbank-stockquote/README | 4 + .../samples/spring-bigbank-stockquote/build.xml | 73 +++ .../samples/spring-bigbank-stockquote/pom.xml | 112 ++++ .../java/bigbank/stockquote/StockQuoteImpl.java | 38 ++ .../java/bigbank/stockquote/StockQuoteService.java | 30 + .../server/SCAApplicationContextProvider.java | 19 + .../stockquote/server/StockQuoteServer.java | 50 ++ .../META-INF/spring/StockQuoteService-context.xml | 36 ++ .../src/main/resources/StockQuote.composite | 35 ++ .../samples/store-distributed/README | 28 + .../samples/store-distributed/build.xml | 79 +++ .../samples/store-distributed/cloud.composite | 27 + .../samples/store-distributed/domain.composite | 27 + .../samples/store-distributed/pom.xml | 119 ++++ .../src/main/java/node/LaunchDomain.java | 33 ++ .../src/main/java/node/LaunchStoreNodeA.java | 28 + .../src/main/java/node/LaunchStoreNodeB.java | 28 + .../src/main/java/node/LaunchStoreNodeC.java | 28 + .../src/main/java/services/Cart.java | 28 + .../src/main/java/services/Catalog.java | 27 + .../src/main/java/services/CurrencyConverter.java | 29 + .../main/java/services/CurrencyConverterImpl.java | 38 ++ .../src/main/java/services/FruitsCatalogImpl.java | 52 ++ .../src/main/java/services/Item.java | 51 ++ .../src/main/java/services/ShoppingCartImpl.java | 112 ++++ .../src/main/java/services/Total.java | 29 + .../src/main/resources/cloud/NodeA.composite | 36 ++ .../src/main/resources/cloud/NodeB.composite | 36 ++ .../src/main/resources/cloud/NodeC.composite | 36 ++ .../resources/nodeA/META-INF/sca-contribution.xml | 24 + .../src/main/resources/nodeA/store.composite | 38 ++ .../resources/nodeB/META-INF/sca-contribution.xml | 24 + .../src/main/resources/nodeB/store.composite | 35 ++ .../resources/nodeC/META-INF/sca-contribution.xml | 24 + .../src/main/resources/nodeC/store.composite | 41 ++ .../src/main/resources/nodeC/uiservices/store.html | 162 +++++ .../src/main/resources/uiservices/store.html | 162 +++++ .../samples/store-distributed/store.png | Bin 0 -> 15670 bytes .../samples/store-distributed/store.svg | 304 ++++++++++ .../samples/store-distributed/workspace.xml | 25 + .../sca-java-20080910/samples/store/README | 28 + .../sca-java-20080910/samples/store/build.xml | 79 +++ .../sca-java-20080910/samples/store/pom.xml | 106 ++++ .../samples/store/src/main/java/launch/Launch.java | 34 ++ .../samples/store/src/main/java/services/Cart.java | 28 + .../store/src/main/java/services/Catalog.java | 27 + .../src/main/java/services/CurrencyConverter.java | 29 + .../main/java/services/CurrencyConverterImpl.java | 38 ++ .../src/main/java/services/FruitsCatalogImpl.java | 52 ++ .../samples/store/src/main/java/services/Item.java | 51 ++ .../src/main/java/services/ShoppingCartImpl.java | 112 ++++ .../store/src/main/java/services/Total.java | 29 + .../store/src/main/resources/store.composite | 64 ++ .../store/src/main/resources/uiservices/store.html | 162 +++++ .../sca-java-20080910/samples/store/store.png | Bin 0 -> 15670 bytes .../sca-java-20080910/samples/store/store.svg | 304 ++++++++++ .../sca-java-20080910/samples/supplychain/README | 101 ++++ .../samples/supplychain/build.xml | 72 +++ .../sca-java-20080910/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-20080910/samples/web-resource/README | 76 +++ .../samples/web-resource/build.xml | 72 +++ .../sca-java-20080910/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 ++ .../samples/web-resource/web-resource.png | Bin 0 -> 8418 bytes .../samples/web-resource/web-resource.svg | 197 ++++++ .../samples/zipcode-jaxws/LICENSE | 205 +++++++ .../sca-java-20080910/samples/zipcode-jaxws/NOTICE | 6 + .../sca-java-20080910/samples/zipcode-jaxws/README | 72 +++ .../samples/zipcode-jaxws/build.xml | 68 +++ .../samples/zipcode-jaxws/pom.xml | 245 ++++++++ .../java/com/example/uszip/GetInfoByAreaCode.java | 81 +++ .../example/uszip/GetInfoByAreaCodeResponse.java | 158 +++++ .../main/java/com/example/uszip/GetInfoByCity.java | 81 +++ .../com/example/uszip/GetInfoByCityResponse.java | 158 +++++ .../java/com/example/uszip/GetInfoByState.java | 81 +++ .../com/example/uszip/GetInfoByStateResponse.java | 158 +++++ .../main/java/com/example/uszip/GetInfoByZIP.java | 81 +++ .../com/example/uszip/GetInfoByZIPResponse.java | 158 +++++ .../main/java/com/example/uszip/ObjectFactory.java | 145 +++++ .../src/main/java/com/example/uszip/USZip.java | 89 +++ .../src/main/java/com/example/uszip/USZipSoap.java | 103 ++++ .../main/java/com/example/uszip/package-info.java | 20 + .../com/example/weather/ArrayOfWeatherData.java | 87 +++ .../com/example/weather/GetWeatherByPlaceName.java | 81 +++ .../weather/GetWeatherByPlaceNameResponse.java | 81 +++ .../com/example/weather/GetWeatherByZipCode.java | 81 +++ .../weather/GetWeatherByZipCodeResponse.java | 81 +++ .../java/com/example/weather/ObjectFactory.java | 118 ++++ .../main/java/com/example/weather/WeatherData.java | 219 +++++++ .../java/com/example/weather/WeatherForecast.java | 91 +++ .../com/example/weather/WeatherForecastSoap.java | 73 +++ .../java/com/example/weather/WeatherForecasts.java | 251 ++++++++ .../java/com/example/weather/package-info.java | 20 + .../src/main/java/location/LocationClient.java | 55 ++ .../src/main/java/location/USLocationImpl.java | 56 ++ .../main/java/weather/WeatherForecastClient.java | 60 ++ .../src/main/java/weather/WeatherForecastImpl.java | 43 ++ .../src/main/java/zipcode/ZipCodeClient.java | 36 ++ .../src/main/java/zipcode/ZipCodeService.java | 30 + .../src/main/java/zipcode/ZipCodeServiceImpl.java | 82 +++ .../src/main/resources/USLocation.composite | 30 + .../src/main/resources/WeatherForecast.composite | 30 + .../src/main/resources/ZipCode.composite | 33 ++ .../test/java/zipcode/ZipCodeClientTestCase.java | 51 ++ 1212 files changed, 75557 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/EchoBinding.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/EchoBindingFactory.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingFactoryImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingPoliciedInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/EchoReferenceBindingProvider.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/EchoServiceBindingProvider.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicy.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicyProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicy.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicyProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionPolicyHandler.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionStrategy.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/PolicyHandler.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/ReverseEncryptionStrategy.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicy.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicyProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/server/EchoServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/server/EchoServiceListener.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/resources/META-INF/services/echo.EchoBindingFactory create mode 100644 sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema create mode 100644 sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/binding-echo-extension/src/main/resources/sample-binding-echo.xsd create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/test/java/echo/Echo.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/test/java/echo/EchoComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/test/java/echo/EchoReferenceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/test/java/echo/EchoServiceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/test/resources/EchoBinding.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/test/resources/definitions.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/binding-echo.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/binding-echo.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/src/main/java/echo/Echo.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/src/main/java/echo/EchoBindingClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/src/main/java/echo/EchoComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/src/main/resources/EchoBinding.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/src/test/java/echo/EchoBindingTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/binding-notification-broker.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/java/notification/broker/TestCaseProducer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisory.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryConsumer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryProducer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/resources/wsdl/TrafficAdvisory.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/binding-notification-consumer.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisory.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryConsumer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/resources/wsdl/TrafficAdvisory.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/test/java/notification/consumer/TrafficAdvisoryTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/binding-notification-producer.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/java/notification/producer/TestCaseProducer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisory.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryProducer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/resources/wsdl/TrafficAdvisory.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/test/java/notification/producer/TrafficAdvisoryTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/calculator-distributed.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/calculator-distributed.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/cloud.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/domain.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeB.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeC.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/node/LaunchDomain.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/cloud/NodeA.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/cloud/NodeB.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/cloud/NodeC.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/test/java/calculator/CalculatorDistributedTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/workspace.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/calculator.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/calculator.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/security/CalculatorCallbackHandler.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/security/JaasLoginModule.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/security/UserPrincipal.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/CalculatorJass.config create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/CalculatorLogMessages.properties create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/test/java/calculator/CalculatorTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/calculator.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/calculator.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/resources/CalculatorTest.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/test/java/calculator/CalculatorTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/calculator.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/calculator.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/META-INF/MANIFEST.MF create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/build.properties create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/icons/alt_window_16.gif create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/icons/alt_window_32.gif create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/plugin.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/Application.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationActionBarAdvisor.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchAdvisor.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchWindowAdvisor.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/Perspective.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/View.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/calculator-rmi-reference.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/calculator-rmi-reference.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/calculator-rmi-service.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/calculator-rmi-service.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/calculator-script.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/calculator-script.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/src/main/resources/calculator/AddServiceImpl.js create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/src/main/resources/calculator/DivideServiceImpl.groovy create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/src/main/resources/calculator/MultiplyServiceImpl.py create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/src/main/resources/calculator/SubtractServiceImpl.rb create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/src/test/java/calculator/CalculatorTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/calculator-web.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/calculator-web.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/webapp/calc.jsp create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/calculator-web.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/calculator-web.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/security/ClientPWCBHandler.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/security/ServerPWCBHandler.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/calculatorKeys.jks create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/security.properties create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/webapp/WEB-INF/geronimo-web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/webapp/calc.jsp create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/calculator-web.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/calculator-web.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/webapp/WEB-INF/geronimo-web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/webapp/calc.jsp create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/calculator.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/calculator.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/test/java/calculator/CalculatorTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/calculator.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/calculator.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/test/java/calculator/CalculatorTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/callback-ws-client.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/callback-ws-client.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myapp/MyClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myapp/MyClientImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myserver/MyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myserver/MyServiceCallback.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/resources/myapp.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/test/java/myapp/CallbackClientTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/callback-ws-service.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/callback-ws-service.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/java/myserver/CallbackServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/java/myserver/MyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/java/myserver/MyServiceCallback.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/java/myserver/MyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/resources/callbackws.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/test/java/myserver/CallbackServerTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderCallback.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderRequest.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderResponse.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderServiceClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/resources/callbacks.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/resources/jndi.properties create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/test/java/callbacks/CallbacksTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/chat-webapp.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/chat-webapp.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/java/sample/ChatService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/java/sample/ChatServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/resources/chat.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/webapp/chat.html create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/java/sample/ChatCallback.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/java/sample/ChatService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/java/sample/ChatServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/resources/chat.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/webapp/chat.html create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/build-dojo.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/customer-dojo-jsonrpc.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/customer-dojo-jsonrpc.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/customer.sql create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/Customer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerCollection.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerCollectionImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/launch/Launch.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/META-INF/orm.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/META-INF/persistence.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/content/customer.html create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/customer.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/databinding-echo.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/databinding-echo.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/src/main/java/dbecho/ComponentAImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/src/main/java/dbecho/ComponentBImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/src/main/java/dbecho/Echo.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/src/main/java/dbecho/EchoDataBindingClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/src/main/java/dbecho/Interface1.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/src/main/java/dbecho/Interface2.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/src/main/resources/EchoDataBinding.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/src/main/resources/wsdl/echo.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/src/test/java/dbecho/EchoDataBindingTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/DistributeComponents.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/ListComponents.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/ListDependencies.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/ListDeployables.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/WireComponents.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/Cart.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/Item.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/ShoppingCartClientImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/ShoppingCartImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assembly/assets.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assembly/client.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assembly/store.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assets/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/client/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/client/client.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/store/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/store/store.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/java/node/DomainServer.java create mode 100755 sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/domain.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/webroot/index.html create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/webroot/node.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/webroot/style.css create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/feed-aggregator-webapp.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/feed-aggregator-webapp.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/java/feed/AggregatorImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/java/feed/Sort.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/java/feed/SortImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/resources/FeedAggregator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/webapp/index.html create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/feed-aggregator.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/feed-aggregator.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/java/feed/Sort.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/java/feed/SortImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/java/launch/LaunchFeedServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/resources/FeedAggregator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTest.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/helloworld-bpel.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/helloworld-bpel.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/java/helloworld/BPELClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/deploy.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.bpel create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/log4j.properties create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/test/java/helloworld/BPELHelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/helloworld-bpel.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/helloworld-bpel.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/deploy.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.bpel create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/log4j.properties create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/java/sample/Helloworld.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/java/sample/HelloworldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/java/sample/HelloworldNode.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/resources/Helloworld.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/java/sample/Helloworld.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/webapp/WEB-INF/web.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/webapp/hello.jsp create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/build-dojo.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/helloworld-jsonrpc.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/helloworld-jsonrpc.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/java/helloworldjsonrpc/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/resources/jsonrpc.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/webapp/HelloWorldJSONRPC.html create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/webapp/style.css create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/java/helloworld/HelloWorldClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/java/helloworld/HelloWorldServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/META-INF/context.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/META-INF/sca-deployables/HelloWorld.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/hello.jsp create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/helloworld-jsonrpc.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/helloworld-jsonrpc.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/java/helloworldjsonrpc/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/resources/jsonrpc.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/webapp/HelloWorldJSONRPC.html create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/webapp/style.css create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/java/sample/HelloworldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/webapp/META-INF/sca-deployables/web.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/webapp/hello.jsp create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/helloworld-reference.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/helloworld-reference.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldJmsClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldServiceComponent.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/resources/helloworldjmsreference.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/resources/helloworldjmsservice.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/resources/logging.properties create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/test/java/helloworld/HelloWorldJmsClientTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/helloworld-service.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/helloworld-service.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/resources/helloworldjmsservice.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/test/java/helloworld/HelloWorldJmsServerTestCaseOff.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/java/sample/HelloworldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/java/sample/HelloworldServlet.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/webapp/META-INF/sca-deployables/web.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/webapp/hello.html create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/java/sample/HelloworldCallback.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/java/sample/HelloworldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/webapp/META-INF/sca-deployables/web.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/webapp/hello.html create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/java/sample/HelloworldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/webapp/META-INF/sca-deployables/web.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/webapp/hello.html create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/resources/META-INF/sca-deployables/helloworldws.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/helloworld-ws-reference.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/helloworld-ws-reference.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldJmsClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldServiceComponent.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjms.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjmsclient.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/resources/logging.properties create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/test/java/helloworld/HelloWorldJmsClientTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/helloworld-ws-reference.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/helloworld-ws-reference.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient2.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient3.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient4.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient5.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient2.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient3.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient4.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient5.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/logging.properties create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/test/java/helloworld/HelloWorldClientTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/test/java/helloworld/HelloWorldTestServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/helloworld-ws-reference-secure.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/helloworld-ws-reference-secure.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/java/helloworld/ClientPWCBHandler.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldServiceComponent.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/helloworldKeys.jks create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/helloworldwsclient.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/logging.properties create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/test/java/helloworld/HelloWorldClientTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/test/java/helloworld/HelloWorldTestServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/helloworld-ws-reference.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/helloworld-ws-reference.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldServiceComponent.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/main/resources/logging.properties create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldClientTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldTestServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/helloworld-ws-sdo-webapp.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/helloworld-ws-sdo-webapp.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorld.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorldComponent.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/resources/helloworldws.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/resources/wsdl/helloworld.xsd create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/webapp/HelloWorld.jsp create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/webapp/WEB-INF/geronimo-web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/helloworld-ws-sdo.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/helloworld-ws-sdo.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServiceComponent.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/resources/helloworldws.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/resources/logging.properties create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldClientTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldTestServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/helloworld-ws-service.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/helloworld-ws-service.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjms.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjmspolicy.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/test/java/helloworld/HelloWorldJmsPolicyServerTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/test/java/helloworld/HelloWorldJmsServerTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/helloworld-ws-service-secure.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/helloworld-ws-service-secure.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/java/helloworld/HelloWorldServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/java/helloworld/ServerPWCBHandler.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/helloworldKeys.jks create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/helloworldws.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/test/java/helloworld/HelloWorldServerTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/webapp/META-INF/sca-deployables/helloworldws.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/webapp/WEB-INF/geronimo-web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/helloworld-ws-service.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/helloworld-ws-service.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/src/main/resources/META-INF/sca-deployables/helloworldws.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/src/test/java/helloworld/HelloWorldServerTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/implementation-composite.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/implementation-composite.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/src/main/java/composite/CompositeClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/src/main/java/composite/Source.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/src/main/java/composite/SourceCallback.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/src/main/java/composite/SourceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/src/main/java/composite/Target.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/src/main/java/composite/TargetImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/src/main/resources/InnerComposite.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/src/main/resources/InnerComposite2.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/src/main/resources/OuterComposite.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/src/test/java/composite/CompositeTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/CRUD.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementation.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementationFactory.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/backend/ResourceManager.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationFactoryImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProvider.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/resources/META-INF/services/crud.CRUDImplementationFactory create mode 100644 sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema create mode 100644 sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-crud-extension/src/main/resources/sample-implementation-crud.xsd create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/test/java/crud/CRUDTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/test/resources/crud.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/implementation-crud.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/implementation-crud.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/src/main/java/crud/client/CRUDClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/src/main/resources/crud.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/src/test/java/crud/client/CRUDTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/implementation-notification.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/main/java/notification/TestCaseProducer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/main/java/notification/TrafficAdvisory.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryConsumer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryProducer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/test/java/notification/TrafficAdvisoryTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema create mode 100644 sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/resources/sample-implementation-pojo.xsd create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/src/main/java/loanapplication/LoanApplication.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/src/main/java/loanapplication/LoanApplicationClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/src/main/java/loanapplication/LoanClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/src/main/java/loanapplication/LoanClientImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/src/main/java/loanapplication/LoanService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/src/main/java/loanapplication/LoanServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/src/main/resources/loanapplication.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/src/test/java/loanapplication/LoanApplicationTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/build-bundles.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/osgi-supplychain.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/osgi-supplychain.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/OSGiBundleImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/SupplyChainClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/customer/Customer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/retailer/Retailer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/shipper/JavaShipperComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/shipper/Shipper.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/warehouse/JavaWarehouseComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/warehouse/Warehouse.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/Customer.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/DSCustomer.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/DSRetailer.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/DSShipper.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/DSWarehouse.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/Retailer.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/Shipper.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/Warehouse.componentType create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/Customer.mf create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/Retailer.mf create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/Shipper.mf create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/Warehouse.mf create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.mf create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.mf create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.mf create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.mf create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/supplychain.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/supplychain.ds.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/photo-gallery.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/photo-gallery.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/launch/LaunchGallery.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/launch/LaunchGalleryJCR.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/services/Album.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/services/AlbumImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/services/jcr/AlbumImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery.html create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00368.jpg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00369.jpg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00370.jpg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00371.jpg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00373.jpg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00375.jpg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00376.jpg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00377.jpg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00378.jpg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00379.jpg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00380.jpg create mode 100755 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/index.gif create mode 100755 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/index_on.gif create mode 100755 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/next.gif create mode 100755 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/next_disabled.gif create mode 100755 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/next_on.gif create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/photo-gallery-jcr.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/photo-gallery.composite create mode 100755 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/prev.gif create mode 100755 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/prev_disabled.gif create mode 100755 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/prev_on.gif create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/show_slide.gif create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/space.gif create mode 100755 sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/styles.css create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderNodeInfo.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/ExternalReferencesQuoteJoin.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProvider.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderNodeInfo.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/PropertiesQuoteJoin.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculator.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculatorImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteDataUtil.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoin.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocal.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocalImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_external_references.xq create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_properties.xq create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/wsdl/AvailQuote.xsd create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/wsdl/PriceQuote.xsd create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/wsdl/Quote.xsd create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/xqueryquotews.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteClientTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteTestServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/build-dojo.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/simple-bigbank-spring.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/simple-bigbank-spring.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountReport.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountDetails.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/feed/AccountFeedImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountDetails.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountDetails.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/server/BigBankServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/stockquote/StockQuoteService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/BigBank.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/SavingsAccount.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/StockAccount.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/Account-spring-context.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/SavingsAccount-context.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/StockAccount/META-INF/MANIFEST.MF create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/StockAccount/META-INF/spring/StockAccount-context.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/web/style.css create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/test/java/bigbank/BigBankTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/simple-bigbank.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/simple-bigbank.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/java/bigbank/account/AccountReport.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/java/bigbank/account/AccountService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/java/bigbank/account/AccountServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/java/bigbank/accountdata/Account.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/java/bigbank/accountdata/CheckingAccount.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/java/bigbank/accountdata/SavingsAccount.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/java/bigbank/accountdata/StockAccount.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/java/bigbank/client/BigBankClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/resources/Account.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/resources/BigBank.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/resources/StockQuote.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/test/java/bigbank/BigBankTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/simple-callback-ws.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/simple-callback-ws.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/main/java/simplecallback/MyClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/main/java/simplecallback/MyClientImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/main/java/simplecallback/MyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceCallback.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/main/java/simplecallback/SimpleCallbackClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/main/resources/simplecallback.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/test/java/simplecallback/SimpleCallbackTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/simple-callback.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/simple-callback.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/src/main/java/simplecallback/MyClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/src/main/java/simplecallback/MyClientImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/src/main/java/simplecallback/MyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/src/main/java/simplecallback/MyServiceCallback.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/src/main/java/simplecallback/MyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/src/main/java/simplecallback/SimpleCallbackClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/src/main/resources/simplecallback.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/src/test/java/simplecallback/SimpleCallbackTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spi-implementation-pojo/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementation.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementationActivator.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spi-implementation-pojo/src/main/java/sample/JavaInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spi-implementation-pojo/src/main/java/sample/JavaInvokerFactory.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorld.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spi-implementation-pojo/src/test/resources/helloworld/helloworld.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/server/CalculatorServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/META-INF/spring/CalculatorService-context.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/AddServiceImpl.js create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/DivideServiceImpl.groovy create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/MultiplyServiceImpl.py create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/SubtractServiceImpl.rb create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountDetails.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/server/CheckingAccountServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/AccountsDataPasswordCallbackHandler.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/BigbankCheckingsAcl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthImplementationPolicyProvider.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicy.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyInterceptor.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyHandler.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/CheckingsAccount.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/spring-context/META-INF/spring/CheckingAccountService-context.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/StockQuoteImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/StockQuoteService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/SCAApplicationContextProvider.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/StockQuoteServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/resources/META-INF/spring/StockQuoteService-context.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/resources/StockQuote.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/cloud.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/domain.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchDomain.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchStoreNodeA.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchStoreNodeB.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchStoreNodeC.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Cart.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Catalog.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/CurrencyConverter.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/CurrencyConverterImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/FruitsCatalogImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Item.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/ShoppingCartImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Total.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/cloud/NodeA.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/cloud/NodeB.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/cloud/NodeC.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeA/store.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeB/store.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeC/store.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeC/uiservices/store.html create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/uiservices/store.html create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/store.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/store.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/workspace.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/launch/Launch.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Cart.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Catalog.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/CurrencyConverter.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/CurrencyConverterImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/FruitsCatalogImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Item.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/ShoppingCartImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Total.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/resources/store.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/resources/uiservices/store.html create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/store.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/store/store.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/src/main/java/supplychain/Customer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/src/main/java/supplychain/CustomerComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/src/main/java/supplychain/Retailer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/src/main/java/supplychain/RetailerComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/src/main/java/supplychain/Shipper.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/src/main/java/supplychain/ShipperComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/src/main/java/supplychain/SupplyChainClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/src/main/java/supplychain/Warehouse.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/src/main/java/supplychain/WarehouseComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/src/main/resources/supplychain.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/supplychain.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/supplychain/supplychain.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/web-resource/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/web-resource/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/web-resource/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/web-resource/src/main/java/web/resource/SampleServer.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/web-resource/src/main/resources/WebResource.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/web-resource/src/main/resources/myContent/index.html create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/web-resource/web-resource.png create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/web-resource/web-resource.svg create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/LICENSE create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/NOTICE create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/README create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/build.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByAreaCode.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByAreaCodeResponse.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByCity.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByCityResponse.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByState.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByStateResponse.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByZIP.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByZIPResponse.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/ObjectFactory.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/USZip.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/USZipSoap.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/package-info.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/ArrayOfWeatherData.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByPlaceName.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByPlaceNameResponse.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByZipCode.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByZipCodeResponse.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/ObjectFactory.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherData.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherForecast.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherForecastSoap.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherForecasts.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/package-info.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/location/LocationClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/location/USLocationImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/weather/WeatherForecastClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/weather/WeatherForecastImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/zipcode/ZipCodeClient.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/zipcode/ZipCodeService.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/zipcode/ZipCodeServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/resources/USLocation.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/resources/WeatherForecast.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/resources/ZipCode.composite create mode 100644 sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/test/java/zipcode/ZipCodeClientTestCase.java (limited to 'sca-java-1.x/branches/sca-java-20080910/samples') diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/README b/sca-java-1.x/branches/sca-java-20080910/samples/README new file mode 100644 index 0000000000..2646fbb73a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/README @@ -0,0 +1,306 @@ +The Apache Tuscany SCA Samples +============================== +The Apache Tuscany SCA samples are built as part of the main Maven build and +run, using the provided JUnit test cases, as tests in the Maven build. + +In the binary distribution of Apache Tuscany most samples can also +be run using the provided Ant build.xml files. These show the samples running +from a simple main() method without the need for a JUnit test case. + +In these notes text that appears in angled brackets like this means +that you need to make a choice and provide your own text at that point. + +These simple samples have been created with the intention of illustrating the +usage of the SCA API and annotations and certainly not to levels of SCA component +abstraction. In real life situations you should use SCA to assemble real and +usually bigger components, and when you do that you'll get all the benefits of +SCA, bindings, policies, integration in an SOA environment etc.. + +Sample Overview +--------------- +The samples generally show off different features of the SCA runtime +and the extensions that come packaged with it. + +binding-notification-broker - A broker for notificatione +binding-notification-consumer - A consumer of notifications +binding-notification-producer - A producer of notifications + +calculator - Calculator built with java components and + local wires. +calculator-distributed - A calculator built using SCA nodes running + on multiple JVMs +calculator-implementation-policies - Shows logging policites associated with + SCA implementations +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 +calculator-script - Calculator built using various script languages +calculator-webapp - Calculator running inside a web app +calculator-ws-webapp - Calculator running inside a web app also + showing webservices binding + +callbck-ws-client - The client for showing callbacks across web services +callback-ws-service - The server for showing callbacks across web serviced + +chat-webapp - A simple chat style web app demonstrating + use of AJAX binding + +databinding-echo - An SCA application that shows how databindings + transform data + +feed-aggregator - Demonstrates using the ATOM binding +feed-aggregator-webapp - feed-aggregator running in webapp + +helloworld-bpel - Demonstrates an SCA component invoking a BPEL + process in a composition + +helloworld-dojo-webapp - An SCA application that exposes a service using + JSONRPC and a client using the Dojo toolkit +helloworld-jsonrpc-webapp - helloworld using jsonrpc binding +helloworld-ws-reference - The client side of a hello world sample that uses a + web service binding (requires helloworld-ws-service) +helloworld-ws-service - The server side of a hello world sample that uses a + web service binding +helloworld-ws-reference-jms - The client side of a hello world sample that uses a + web service binding with SOAP/JMS (requires + helloworld-ws-service) +helloworld-ws-service-jms - The server side of a hello world sample that + uses a web service binding with SOAP/JMS +helloworld-ws-reference-secure - The client side of a hello world sample that + shows how policy intent can be used. +helloworld-ws-service-secure - The client side of a hello world sample that + shows how policy intent can be used. +helloworld-ws-sdo - helloworld using ws binding and SDO +helloworld-ws-sdo-webapp - helloworld using ws binding and SDO within a webapp + +implementation-composite - Shows how SCA composites are used + +osgi-supplychain - SCA asynchronous API with OSGi and Java + implementation types + +simple-bigbank - A banking application built with java components + and local wire +simple-bigbank-spring - A banking application showing how SCA works with Spring + +simple-callback - demonstrates the callback interface +simple-callback-ws - demonstrates use of callback interface across WS binding + +store - Step by step guide for creating an online store + +supplychain - shows how asynchronous callbacks can be used + +web-resource - Demonstrates using an SCA Web resource component + +quote-xquery - Demonstrate SCA components using XQuery + +Samples for building extensions +------------------------------- +There are 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 +implementation-notifiaction- Illustrates the use of +implementation-pojo-extension - shows how new implementation types are constructed + +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-1.0-incubating\samples\calculator from the filesystem + Configure the source path to include + src/main/java + src/main/resources + Configure the output folder to be + calculator/target + Configure the build path to include 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-20080910/samples/binding-echo-extension/README b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/README new file mode 100644 index 0000000000..94716b151f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/binding-echo-extension/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/build.xml new file mode 100644 index 0000000000..5df5981bea --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/build.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/pom.xml new file mode 100644 index 0000000000..2d516f2101 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-binding-echo-extension + Apache Tuscany SCA Echo Binding Extension Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/EchoBinding.java b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/EchoBinding.java new file mode 100644 index 0000000000..3fe1598e0d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/EchoBinding.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; + +import org.apache.tuscany.sca.assembly.Binding; + +/** + * A model for the sample Echo binding. + */ +public interface EchoBinding extends Binding { + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/EchoBindingFactory.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingFactoryImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingImpl.java new file mode 100644 index 0000000000..19c9271bb8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingImpl.java @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package 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 org.apache.tuscany.sca.policy.PolicySetAttachPoint; + +import echo.EchoBinding; + +/** + * Implementation of the Echo binding model. + */ +public class EchoBindingImpl implements EchoBinding, PolicySetAttachPoint { + + private String name; + private String uri; + private List requiredIntents = new ArrayList(); + private List policySets = new ArrayList(); + private List applicablePolicySets = 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 + } + + public void setPolicySets(List policySets) { + this.policySets = policySets; + + } + + public void setRequiredIntents(List intents) { + this.requiredIntents = intents; + + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public List getApplicablePolicySets() { + return this.applicablePolicySets; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingProcessor.java b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingProcessor.java new file mode 100644 index 0000000000..45fdb73f67 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingProcessor.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 echo.impl; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor; +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.Intent; +import org.apache.tuscany.sca.policy.PolicyFactory; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.IntentAttachPointType; +import org.apache.tuscany.sca.policy.impl.IntentAttachPointTypeFactoryImpl; + +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 PolicyAttachPointProcessor policyProcessor; + + public EchoBindingProcessor(EchoBindingFactory factory, PolicyFactory policyFactory) { + this.factory = factory; + this.policyProcessor = new PolicyAttachPointProcessor(policyFactory); + } + + public QName getArtifactType() { + return BINDING_ECHO; + } + + public Class getModelType() { + return EchoBinding.class; + } + + public EchoBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + EchoBinding echoBinding = factory.createEchoBinding(); + IntentAttachPointType bindingType = new IntentAttachPointTypeFactoryImpl().createBindingType(); + bindingType.setName(getArtifactType()); + bindingType.setUnresolved(true); + ((PolicySetAttachPoint)echoBinding).setType(bindingType); + + String name = reader.getAttributeValue(null, "name"); + if (name != null) { + echoBinding.setName(name); + } + + String uri = reader.getAttributeValue(null, "uri"); + if (uri != null) { + echoBinding.setURI(uri); + } + + policyProcessor.readPolicies(echoBinding, reader); + + return echoBinding; + } + + public void write(EchoBinding echoBinding, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { + + policyProcessor.writePolicyPrefixes(echoBinding, writer); + writer.writeStartElement(BINDING_ECHO.getNamespaceURI(), BINDING_ECHO.getLocalPart()); + policyProcessor.writePolicyAttributes(echoBinding, writer); + + if (echoBinding.getName() != null) { + writer.writeAttribute("name", echoBinding.getName()); + } + + if (echoBinding.getURI() != null) { + writer.writeAttribute("uri", echoBinding.getURI()); + } + + writer.writeEndElement(); + } + + public void resolve(EchoBinding echoBinding, ModelResolver resolver) throws ContributionResolveException { + PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)echoBinding; + List requiredIntents = new ArrayList(); + Intent resolvedIntent = null; + for ( Intent intent : policySetAttachPoint.getRequiredIntents() ) { + resolvedIntent = resolver.resolveModel(Intent.class, intent); + requiredIntents.add(resolvedIntent); + } + policySetAttachPoint.getRequiredIntents().clear(); + policySetAttachPoint.getRequiredIntents().addAll(requiredIntents); + + List resolvedPolicySets = new ArrayList(); + PolicySet resolvedPolicySet = null; + for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) { + resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet); + resolvedPolicySets.add(resolvedPolicySet); + } + policySetAttachPoint.getPolicySets().clear(); + policySetAttachPoint.getPolicySets().addAll(resolvedPolicySets); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingInvoker.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingPoliciedInvoker.java b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingPoliciedInvoker.java new file mode 100644 index 0000000000..4877bade7f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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://test","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-20080910/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingProviderFactory.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/java/echo/provider/EchoReferenceBindingProvider.java b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/EchoReferenceBindingProvider.java new file mode 100644 index 0000000000..0efc319af9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/EchoReferenceBindingProvider.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 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.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) { + if (binding instanceof PolicySetAttachPoint) { + PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)binding; + if ( !policySetAttachPoint.getPolicySets().isEmpty() ){ + return new EchoBindingPoliciedInvoker(policySetAttachPoint.getPolicySets()); + } + } + return new EchoBindingInvoker(); + } + + public boolean supportsOneWayInvocation() { + return false; + } + + public InterfaceContract getBindingInterfaceContract() { + return reference.getInterfaceContract(); + } + + public void start() { + } + + public void stop() { + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/EchoServiceBindingProvider.java b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/EchoServiceBindingProvider.java new file mode 100644 index 0000000000..1cd1e5af4e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/EchoServiceBindingProvider.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; + +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 boolean supportsOneWayInvocation() { + return false; + } + + 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-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicy.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicyProcessor.java b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicyProcessor.java new file mode 100644 index 0000000000..c847d088a6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicyProcessor.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 echo.provider.policy; + +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.monitor.Monitor; + + +/** + * + */ +public class EchoBindingEncryptionPolicyProcessor extends EchoBindingPolicyProcessor { + + public EchoBindingEncryptionPolicyProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + } + + public Class getModelType() { + return EchoBindingEncryptionPolicy.class; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicy.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicyProcessor.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionPolicyHandler.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionStrategy.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/PolicyHandler.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/ReverseEncryptionStrategy.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicy.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicyProcessor.java b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicyProcessor.java new file mode 100644 index 0000000000..fcb250b444 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicyProcessor.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 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; + +public class WSPolicyProcessor implements StAXArtifactProcessor { + + public QName getArtifactType() { + return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment"); + } + + public WSPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + //FIXME Implement this method + return new WSPolicy(); + } + + public void write(WSPolicy wsPolicy, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { + //FIXME Implement this method + } + + public Class getModelType() { + return WSPolicy.class; + } + + public void resolve(WSPolicy wsPolicy, ModelResolver modelResolver) throws ContributionResolveException { + + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/java/echo/server/EchoServer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/java/echo/server/EchoServiceListener.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/resources/META-INF/services/echo.EchoBindingFactory b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/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-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema new file mode 100644 index 0000000000..4ad61f573d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# URI of the XML schema to be used for validation +sample-binding-echo.xsd diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/main/resources/sample-binding-echo.xsd b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/resources/sample-binding-echo.xsd new file mode 100644 index 0000000000..9b64df4871 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/main/resources/sample-binding-echo.xsd @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/test/java/echo/Echo.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/test/java/echo/EchoComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/test/java/echo/EchoReferenceTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/test/java/echo/EchoServiceTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo-extension/src/test/resources/EchoBinding.composite b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/test/resources/EchoBinding.composite new file mode 100644 index 0000000000..176d67cc4b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/test/resources/EchoBinding.composite @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/test/resources/definitions.xml b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/test/resources/definitions.xml new file mode 100644 index 0000000000..1cb1d1c9ba --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo-extension/src/test/resources/definitions.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + Communitcation thro this binding must prevent + unauthorized users from reading the messages. + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/README b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/README new file mode 100644 index 0000000000..2772460cc6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/README @@ -0,0 +1,104 @@ +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 + +Note: this sample currently is not working on Linux + +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] Passing thro invoker... + [java] Returned message: foo + [java] Echo reference = foo + [java] Passing thro invoker... + [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 +Passing thro invoker... +Returned message: foo +Passing thro invoker... +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-20080910/samples/binding-echo/binding-echo.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/binding-echo/binding-echo.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/binding-echo.svg b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/binding-echo.svg new file mode 100644 index 0000000000..5b5051bef5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/binding-echo/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/build.xml new file mode 100644 index 0000000000..7689ef3a54 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/build.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/pom.xml new file mode 100644 index 0000000000..9c14b5d4c3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/pom.xml @@ -0,0 +1,71 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-binding-echo + Apache Tuscany SCA Echo Binding Sample Application + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + sample-binding-echo-extension + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/src/main/java/echo/Echo.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo/src/main/java/echo/EchoBindingClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo/src/main/java/echo/EchoComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-echo/src/main/resources/EchoBinding.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/binding-echo/src/main/resources/EchoBinding.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-echo/src/test/java/echo/EchoBindingTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-notification-broker/README b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/README new file mode 100644 index 0000000000..e47f12cb20 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/README @@ -0,0 +1,110 @@ +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 Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant as +follows + +cd binding-notification-broker +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] Sep 14, 2007 11:14:24 AM org.apache.tuscany.sca.http.jetty.JettyServer addServletMapping + [java] INFO: Added Servlet mapping: http://localhost:8083/ntm/trafficAdvisory + [java] Sep 14, 2007 11:14:24 AM org.apache.tuscany.sca.http.jetty.JettyServer addServletMapping + [java] INFO: Added Servlet mapping: http://localhost:8083/consumer/trafficAdvisory + [java] Sep 14, 2007 11:14:24 AM org.apache.tuscany.sca.http.jetty.JettyServer addServletMapping + [java] INFO: Added Servlet mapping: http://localhost:8083/producer/trafficAdvisory + +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 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.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-20080910/samples/binding-notification-broker/binding-notification-broker.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/binding-notification-broker/binding-notification-broker.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/build.xml new file mode 100644 index 0000000000..a042b9036a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/build.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/pom.xml new file mode 100644 index 0000000000..8043379003 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/pom.xml @@ -0,0 +1,97 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-binding-notification-broker + Apache Tuscany SCA Notification Binding Broker Sample + 1.4-SNAPSHOT + A sample illustrating use of binding.notification + + + + org.apache.tuscany.sca + tuscany-implementation-notification + 1.4-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-binding-notification + 1.4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-databinding + 1.4-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-interface-wsdl + 1.4-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-interface-wsdl-xml + 1.4-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-20080910/samples/binding-notification-broker/src/main/java/notification/broker/TestCaseProducer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisory.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryConsumer.java b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryConsumer.java new file mode 100644 index 0000000000..cd3befe076 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryConsumer.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 notification.broker; + +import org.osoa.sca.annotations.AllowsPassByReference; +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") +@AllowsPassByReference +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-20080910/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryProducer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryServer.java new file mode 100644 index 0000000000..b0f0d2a800 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryServer.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package 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 = ""; + if (args.length == 1) { + value = args[0]; + } + do { + if(value == null || value.equals("end")) { + break; + } + try { + System.out.println("Send a report value, ^C or to end"); + value = reader.readLine(); + } catch (IOException e) { + e.printStackTrace(); + } + 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-20080910/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.componentType b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.componentType new file mode 100644 index 0000000000..2dc70f8ed1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.componentType @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.composite b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.composite new file mode 100644 index 0000000000..f490c34ea6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Consumer1 + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-broker/src/main/resources/wsdl/TrafficAdvisory.wsdl b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/binding-notification-broker/src/main/resources/wsdl/TrafficAdvisory.wsdl @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/README b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/README new file mode 100644 index 0000000000..0fdfa8461a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/README @@ -0,0 +1,102 @@ +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 Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant as +follows + +cd binding-notification-consumer +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] Sep 14, 2007 10:56:29 AM org.apache.tuscany.sca.http.jetty.JettyServer addServletMapping + [java] INFO: Added Servlet mapping: http://localhost:8083/ntm/trafficAdvisory + [java] Sep 14, 2007 10:56:29 AM org.apache.tuscany.sca.http.jetty.JettyServer addServletMapping + [java] INFO: Added Servlet mapping: http://localhost:8083/consumer/trafficAdvisory + +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 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.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-20080910/samples/binding-notification-consumer/binding-notification-consumer.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/binding-notification-consumer/binding-notification-consumer.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/build.xml new file mode 100644 index 0000000000..f57fe1bb26 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/build.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/pom.xml new file mode 100644 index 0000000000..5b1fc256f6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/pom.xml @@ -0,0 +1,115 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-binding-notification-consumer + Apache Tuscany SCA Notification Binding Consumer Sample + 1.4-SNAPSHOT + A sample illustrating use of binding.notification + + + + org.apache.tuscany.sca + tuscany-implementation-notification + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-notification + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-interface-java-xml + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-interface-wsdl-xml + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + notification.httpPort + 8083 + + + + + + install + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisory.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryConsumer.java b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryConsumer.java new file mode 100644 index 0000000000..f6c27a2f55 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryConsumer.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 notification.consumer; + +import org.osoa.sca.annotations.AllowsPassByReference; +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") +@AllowsPassByReference +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-20080910/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryServer.java new file mode 100644 index 0000000000..c53adb1944 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryServer.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 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 { + if (args.length != 1 || !args[0].equals("end")) { + 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-20080910/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.componentType b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.componentType new file mode 100644 index 0000000000..2dc70f8ed1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.componentType @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.composite b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.composite new file mode 100644 index 0000000000..8f9bcc4438 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.composite @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + Consumer1 + + + + + Consumer2 + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/main/resources/wsdl/TrafficAdvisory.wsdl b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/binding-notification-consumer/src/main/resources/wsdl/TrafficAdvisory.wsdl @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/test/java/notification/consumer/TrafficAdvisoryTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/test/java/notification/consumer/TrafficAdvisoryTestCase.java new file mode 100644 index 0000000000..c5318f405c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-consumer/src/test/java/notification/consumer/TrafficAdvisoryTestCase.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 notification.consumer; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +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 ..."); + + /* Uncomment to test with producer + try { + System.out.println("TrafficAdvisoryServer, hit return to end"); + System.in.read(); + } catch (Exception e) { + e.printStackTrace(); + } + */ + } + + @Override + protected void setUp() throws Exception { + try { + domain = SCADomain.newInstance("TrafficAdvisoryNotification.composite"); + } 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-20080910/samples/binding-notification-producer/README b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/README new file mode 100644 index 0000000000..58611f64bd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/README @@ -0,0 +1,131 @@ +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 Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant as +follows + +cd binding-notification-producer +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] Sep 14, 2007 10:31:45 AM org.apache.tuscany.sca.http.jetty.JettyServer addServletMapping + [java] INFO: Added Servlet mapping: http://localhost:8083/ntm/trafficAdvisory + [java] Sep 14, 2007 10:31:45 AM org.apache.tuscany.sca.http.jetty.JettyServer addServletMapping + [java] INFO: Added Servlet mapping: http://localhost:8083/producer/trafficAdvisory + +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 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.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-20080910/samples/binding-notification-producer/binding-notification-producer.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/binding-notification-producer/binding-notification-producer.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/build.xml new file mode 100644 index 0000000000..d13e4c8a6c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/build.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/pom.xml new file mode 100644 index 0000000000..a35fbb0339 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/pom.xml @@ -0,0 +1,126 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-binding-notification-producer + Apache Tuscany SCA Notification Binding Producer Sample + 1.4-SNAPSHOT + A sample illustrating use of binding.notification + + + + org.apache.tuscany.sca + tuscany-implementation-notification + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-notification + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-interface-wsdl-xml + 1.4-SNAPSHOT + runtime + + + + javax.servlet + servlet-api + 2.5 + provided + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.4-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 + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + notification.httpPort + 8083 + + + + + + install + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/java/notification/producer/TestCaseProducer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisory.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryProducer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryServer.java new file mode 100644 index 0000000000..efd3657dc3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryServer.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 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 = ""; + if (args.length == 1) { + value = args[0]; + } + do { + if(value == null || value.equals("end")) { + break; + } + try { + System.out.println("Send a report value, ^C or to end"); + value = reader.readLine(); + } catch (IOException e) { + e.printStackTrace(); + } + testCaseProducer.produceTrafficNotification("Report value [" + value + "]"); + } + while(true); + + domain.close(); + } catch(Throwable e) { + e.printStackTrace(); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.componentType b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.componentType new file mode 100644 index 0000000000..2dc70f8ed1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.componentType @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.composite b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.composite new file mode 100644 index 0000000000..2db6ea655b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/main/resources/wsdl/TrafficAdvisory.wsdl b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/binding-notification-producer/src/main/resources/wsdl/TrafficAdvisory.wsdl @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/test/java/notification/producer/TrafficAdvisoryTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/test/java/notification/producer/TrafficAdvisoryTestCase.java new file mode 100644 index 0000000000..d3901ee407 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/binding-notification-producer/src/test/java/notification/producer/TrafficAdvisoryTestCase.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 notification.producer; + +import java.io.BufferedReader; +import java.io.InputStreamReader; + +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 ..."); + TestCaseProducer testCaseProducer = domain.getService(TestCaseProducer.class, "TrafficAdvisoryProducer"); + + /* Uncomment to test with consumer + BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); + String value = "foo"; + do { + try { + System.out.println("Send a report value, ^C or to end"); + value = reader.readLine(); + } catch (Exception e) { + e.printStackTrace(); + } + if(value == null || value.equals("end")) { + break; + } + testCaseProducer.produceTrafficNotification("Report value [" + value + "]"); + value = "end"; + } + while(true); + */ + } + + @Override + protected void setUp() throws Exception { + try { + domain = SCADomain.newInstance("TrafficAdvisoryNotification.composite"); + } 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-20080910/samples/calculator-distributed/README b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/README new file mode 100644 index 0000000000..51f4b07e81 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/README @@ -0,0 +1,438 @@ +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 runDomain +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.LaunchDomain +java -cp src\main\resources;..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-distributed.jar node.LaunchCalculatorNodeB +java -cp src\main\resources;..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-distributed.jar node.LaunchCalculatorNodeC +java -cp src\main\resources;..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-distributed.jar node.LaunchCalculatorNodeA + +and on *nix do + +java -cp src/main/resources:../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.LaunchDomain +java -cp src/main/resources:../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.LaunchCalculatorNodeB +java -cp src/main/resources:../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.LaunchCalculatorNodeC +java -cp src/main/resources:../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.LaunchCalculatorNodeA + + +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 see the output of invoking the +calculator functions distributed over NodeB and and NodeC. On the command prompts +where you have started NodeB and NodeC, you see log messages that indicate that +the add and subtract 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. + +The domain node makes available a web application through which the contributions and +composites used in this sample can be navigated. One you have run "ant runDomain" you can +point you browser at: + +http://localhost:9990/ui/workspace/ + +The contents of the sample are as follows: + +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/ + LaunchCalculatorNodeA.java - runs an sca node configured with the + composite describing the main calculator + application. If you look inside this class + you will see that the node is configured + using a URL of the form: + + http://localhost:9990/node-config/NodeA + + This retrieves the information required + to configure NodeA from the domain. + + Once the node has been started this launcher + then finds the calculator service and + calls the various methods. + + LaunchCalculatorNodeB&C.java - These launchers start nodes B and C + which runs the add and subtract services. + + Unlike NodeA though these launchers just + wait once the node has been started. They + will service incomming web service requests + as they arrive. + + LaunchDomain.java - the node that provides the domain + configuration to the distributed + nodes + resources/ + cloud - The SCA composite files that describe + the configuration of each node + 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 nodeC's part of the + calculator application + test/ + java/ + calculator/ + CalculatorDistributedTestCase.java - JUnit test case which runs all + of the separate nodes along with the domain + 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 runDomain +ant runNodeB +ant runNodeC +ant runNodeA + +You should see the following output from the four separate command prompt: + +runDomain: +ted>ant runDomain +Buildfile: build.xml + +runDomain: + [java] 26-Mar-2008 12:55:12 org.apache.tuscany.sca.node.launcher.DomainMana +gerLauncher main + [java] INFO: Apache Tuscany SCA Domain Manager starting... + [java] 26-Mar-2008 12:55:13 org.apache.tuscany.sca.node.launcher.NodeLaunch +erUtil collectJARFiles + [java] INFO: Runtime classpath: 147 JARs from C:\simon\tuscany\sca-java-1.2 +\distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca- +1.2-incubating-SNAPSHOT\lib + [java] 26-Mar-2008 12:55:13 org.apache.tuscany.sca.node.launcher.NodeLaunch +erUtil collectJARFiles + [java] INFO: Runtime classpath: 89 JARs from C:\simon\tuscany\sca-java-1.2\ +distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca-1 +.2-incubating-SNAPSHOT\modules + [java] 26-Mar-2008 12:55:19 org.apache.catalina.core.StandardEngine start + [java] INFO: Starting Servlet Engine: Apache Tomcat/6.0.14 + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.ContextConfig defau +ltWebConfig + [java] INFO: No default web.xml + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg +ister + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0. +xsd + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg +ister + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_1. +xsd + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg +ister + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt +aglibrary_1_1.dtd + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg +ister + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt +aglibrary_1_2.dtd + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg +ister + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt +aglibrary_2_0.xsd + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg +ister + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt +aglibrary_2_1.xsd + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg +ister + [java] WARNING: Could not get url for /javax/servlet/resources/j2ee_web_ser +vices_1_1.xsd + [java] 26-Mar-2008 12:55:20 org.apache.coyote.http11.Http11Protocol init + [java] INFO: Initializing Coyote HTTP/1.1 on http-9990 + [java] 26-Mar-2008 12:55:20 org.apache.coyote.http11.Http11Protocol start + [java] INFO: Starting Coyote HTTP/1.1 on http-9990 + [java] 26-Mar-2008 12:55:20 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/ui/home/* + [java] 26-Mar-2008 12:55:20 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/ui/workspace/* + [java] 26-Mar-2008 12:55:20 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/ui/files/* + [java] 26-Mar-2008 12:55:20 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/ui/composite/* + [java] 26-Mar-2008 12:55:20 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/ui/cloud/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/workspace/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/contribution/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/feed/files/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/files/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/composite/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/composite-source/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/deployable/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/composite-resolved/ +* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/cloud/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/cloud-source/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/composite-config/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/node-config/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/quickstart/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/processes/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/node/processes/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/ping/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.node.launcher.DomainMana +gerLauncher main + [java] INFO: SCA Domain Manager started. + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.node.launcher.DomainMana +gerLauncher main + [java] INFO: Press enter to shutdown. + + +runNodeB: + [java] 26-Mar-2008 12:55:42 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: Apache Tuscany SCA Node starting... + [java] 26-Mar-2008 12:55:42 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: SCA Node configuration: http://localhost:9990/node-config/NodeB + + [java] 26-Mar-2008 12:55:42 org.apache.tuscany.sca.node.launcher.NodeLaunch +erUtil collectJARFiles + [java] INFO: Runtime classpath: 147 JARs from C:\simon\tuscany\sca-java-1.2 +\distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca- +1.2-incubating-SNAPSHOT\lib + [java] 26-Mar-2008 12:55:42 org.apache.tuscany.sca.node.launcher.NodeLaunch +erUtil collectJARFiles + [java] INFO: Runtime classpath: 89 JARs from C:\simon\tuscany\sca-java-1.2\ +distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca-1 +.2-incubating-SNAPSHOT\modules + [java] 26-Mar-2008 12:55:42 org.apache.tuscany.sca.node.impl.NodeImpl + [java] INFO: Creating node: http://localhost:9990/node-config/NodeB + [java] 26-Mar-2008 12:55:45 org.apache.tuscany.sca.node.impl.NodeImpl confi +gureNode + [java] INFO: Loading contribution: file:/C:/simon/tuscany/sca-java-1.2/dist +ribution/target/apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir/tuscany-sca-1.2-i +ncubating-SNAPSHOT/samples/calculator-distributed/./src/main/resources/nodeB/ + [java] 26-Mar-2008 12:55:46 org.apache.tuscany.sca.node.impl.NodeImpl confi +gureNode + [java] INFO: Loading composite: http://localhost:9990/composite-resolved/co +mposite:nodeB;http://sample;CalculatorB + [java] 26-Mar-2008 12:55:47 org.apache.tuscany.sca.node.impl.NodeImpl start + + [java] INFO: Starting node: http://localhost:9990/node-config/NodeB + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] 26-Mar-2008 12:55:53 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:8200/AddServiceComponent +B + [java] 26-Mar-2008 12:55:53 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: SCA Node started. + [java] 26-Mar-2008 12:55:53 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: Press enter to shutdown. + [java] AddService - add 3.0 and 2.0 + +runNodeC: + [java] 26-Mar-2008 12:56:01 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: Apache Tuscany SCA Node starting... + [java] 26-Mar-2008 12:56:01 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: SCA Node configuration: http://localhost:9990/node-config/NodeC + + [java] 26-Mar-2008 12:56:01 org.apache.tuscany.sca.node.launcher.NodeLaunch +erUtil collectJARFiles + [java] INFO: Runtime classpath: 147 JARs from C:\simon\tuscany\sca-java-1.2 +\distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca- +1.2-incubating-SNAPSHOT\lib + [java] 26-Mar-2008 12:56:01 org.apache.tuscany.sca.node.launcher.NodeLaunch +erUtil collectJARFiles + [java] INFO: Runtime classpath: 89 JARs from C:\simon\tuscany\sca-java-1.2\ +distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca-1 +.2-incubating-SNAPSHOT\modules + [java] 26-Mar-2008 12:56:01 org.apache.tuscany.sca.node.impl.NodeImpl + [java] INFO: Creating node: http://localhost:9990/node-config/NodeC + [java] 26-Mar-2008 12:56:03 org.apache.tuscany.sca.node.impl.NodeImpl confi +gureNode + [java] INFO: Loading contribution: file:/C:/simon/tuscany/sca-java-1.2/dist +ribution/target/apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir/tuscany-sca-1.2-i +ncubating-SNAPSHOT/samples/calculator-distributed/./src/main/resources/nodeC/ + [java] 26-Mar-2008 12:56:04 org.apache.tuscany.sca.node.impl.NodeImpl confi +gureNode + [java] INFO: Loading composite: http://localhost:9990/composite-resolved/co +mposite:nodeC;http://sample;CalculatorC + [java] 26-Mar-2008 12:56:04 org.apache.tuscany.sca.node.impl.NodeImpl start + + [java] INFO: Starting node: http://localhost:9990/node-config/NodeC + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] 26-Mar-2008 12:56:10 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:8300/SubtractServiceComp +onentC + [java] 26-Mar-2008 12:56:10 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: SCA Node started. + [java] 26-Mar-2008 12:56:10 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: Press enter to shutdown. + [java] SubtractService - subtract 3.0 and 2.0 + +runNodeA: + [java] 26-Mar-2008 12:56:10 org.apache.tuscany.sca.node.impl.NodeImpl + [java] INFO: Creating node: http://localhost:9990/node-config/NodeA + [java] 26-Mar-2008 12:56:12 org.apache.tuscany.sca.node.impl.NodeImpl confi +gureNode + [java] INFO: Loading contribution: file:/C:/simon/tuscany/sca-java-1.2/dist +ribution/target/apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir/tuscany-sca-1.2-i +ncubating-SNAPSHOT/samples/calculator-distributed/./src/main/resources/nodeA/ + [java] 26-Mar-2008 12:56:13 org.apache.tuscany.sca.node.impl.NodeImpl confi +gureNode + [java] INFO: Loading composite: http://localhost:9990/composite-resolved/co +mposite:nodeA;http://sample;CalculatorA + [java] 26-Mar-2008 12:56:14 org.apache.tuscany.sca.assembly.builder.impl.Co +mpositeBuilderImpl$1 problem + [java] WARNING: Component reference target not found, it might be a remote +service: SubtractServiceComponentC + [java] 26-Mar-2008 12:56:14 org.apache.tuscany.sca.assembly.builder.impl.Co +mpositeBuilderImpl$1 problem + [java] WARNING: Component reference target not found, it might be a remote +service: AddServiceComponentB + [java] 26-Mar-2008 12:56:14 org.apache.tuscany.sca.node.impl.NodeImpl start + + [java] INFO: Starting node: http://localhost:9990/node-config/NodeA + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [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 + [java] 26-Mar-2008 12:56:20 org.apache.tuscany.sca.node.impl.NodeImpl stop + [java] INFO: Stopping node: http://localhost:9990/node-config/NodeA + +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 at the end of the test phase. + +INFO: Starting node: http://localhost:9990/node-config/NodeA +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 +26-Mar-2008 13:00:52 org.apache.tuscany.sca.node.impl.NodeImpl stop +INFO: Stopping node: http://localhost:9990/node-config/NodeC +26-Mar-2008 13:00:52 org.apache.tuscany.sca.node.impl.NodeImpl stop +INFO: Stopping node: http://localhost:9990/node-config/NodeB +26-Mar-2008 13:00:52 org.apache.tuscany.sca.node.impl.NodeImpl stop +INFO: Stopping node: http://localhost:9990/node-config/NodeA +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 13.328 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-20080910/samples/calculator-distributed/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/build.xml new file mode 100644 index 0000000000..cccd22f3ae --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/build.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/calculator-distributed.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-distributed/calculator-distributed.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/calculator-distributed.svg b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/calculator-distributed.svg new file mode 100644 index 0000000000..be5a4b8185 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-distributed/cloud.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/cloud.composite new file mode 100644 index 0000000000..85e2f9c7f3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/cloud.composite @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/domain.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/domain.composite new file mode 100644 index 0000000000..643e22d0cf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/domain.composite @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/pom.xml new file mode 100644 index 0000000000..a0f04d4a1a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/pom.xml @@ -0,0 +1,119 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-calculator-distributed + Apache Tuscany SCA Distributed Calculator Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-launcher + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-domain-manager + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-node-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-sca + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-sca-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-resource-runtime + 1.4-SNAPSHOT + runtime + + + + org.codehaus.woodstox + wstx-asl + 3.2.1 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.4-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-distributed/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-distributed/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-distributed/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-distributed/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-distributed/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-distributed/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-distributed/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-distributed/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-distributed/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java new file mode 100644 index 0000000000..3ff6c8969a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.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 node; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.launcher.NodeLauncher; +import org.osoa.sca.ServiceRuntimeException; + +import calculator.CalculatorService; + +public class LaunchCalculatorNodeA { + public static void main(String[] args) throws Exception { + + SCANode node = null; + try { + + NodeLauncher nodeLauncher = NodeLauncher.newInstance(); + node = nodeLauncher.createNodeFromURL("http://localhost:9990/node-config/NodeA"); + + node.start(); + + // get a reference to the calculator component + SCAClient client = (SCAClient)node; + CalculatorService calculatorService = + client.getService(CalculatorService.class, "CalculatorServiceComponentA"); + + // 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)); + + if (args.length > 1){ + for (int i=0; i < 1000; i++){ + // Calculate + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + } + } + + node.stop(); + + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeB.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeB.java new file mode 100644 index 0000000000..50600eaedc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeB.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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 org.apache.tuscany.sca.node.launcher.NodeLauncher; + +public class LaunchCalculatorNodeB { + public static void main(String[] args) throws Exception { + NodeLauncher.main(new String[] {"http://localhost:9990/node-config/NodeB"}); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeC.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeC.java new file mode 100644 index 0000000000..95d8934665 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeC.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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 org.apache.tuscany.sca.node.launcher.NodeLauncher; + +public class LaunchCalculatorNodeC { + public static void main(String[] args) throws Exception { + NodeLauncher.main(new String[] {"http://localhost:9990/node-config/NodeC"}); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/node/LaunchDomain.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/node/LaunchDomain.java new file mode 100644 index 0000000000..8b4fe566a1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/java/node/LaunchDomain.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 node; + +import org.apache.tuscany.sca.node.launcher.DomainManagerLauncher; + +/** + * 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 LaunchDomain { + public static void main(String[] args) throws Exception { + DomainManagerLauncher.main(args); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/cloud/NodeA.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/cloud/NodeA.composite new file mode 100644 index 0000000000..ed7fe55abc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/cloud/NodeA.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/cloud/NodeB.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/cloud/NodeB.composite new file mode 100644 index 0000000000..8f29cc17aa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/cloud/NodeB.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/cloud/NodeC.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/cloud/NodeC.composite new file mode 100644 index 0000000000..9ad132b0d4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/cloud/NodeC.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite new file mode 100644 index 0000000000..172676a3c7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..1b1c0291e2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite new file mode 100644 index 0000000000..b770dbe8d4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..6c0ffe4ac0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite new file mode 100644 index 0000000000..66caf0d17b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..8c311553c3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-distributed/src/test/java/calculator/CalculatorDistributedTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/test/java/calculator/CalculatorDistributedTestCase.java new file mode 100644 index 0000000000..2a6f3af002 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/src/test/java/calculator/CalculatorDistributedTestCase.java @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + + +import junit.framework.Assert; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.apache.tuscany.sca.node.launcher.DomainManagerLauncher; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Runs a distributed domain in a single VM by using and in memory + * implementation of the distributed domain + */ +public class CalculatorDistributedTestCase { + + private static SCANode manager; + private static SCANode nodeA; + private static SCANode nodeB; + private static SCANode nodeC; + + private static CalculatorService calculatorService; + + + @BeforeClass + public static void init() throws Exception { + + try { + System.out.println("Setting up domain"); + + DomainManagerLauncher managerLauncher = DomainManagerLauncher.newInstance(); + manager = managerLauncher.createDomainManager(); + manager.start(); + + SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + nodeC = nodeFactory.createSCANodeFromURL("http://localhost:9990/node-config/NodeC"); + nodeB = nodeFactory.createSCANodeFromURL("http://localhost:9990/node-config/NodeB"); + nodeA = nodeFactory.createSCANodeFromURL("http://localhost:9990/node-config/NodeA"); + + nodeC.start(); + nodeB.start(); + nodeA.start(); + + SCAClient client = (SCAClient)nodeA; + calculatorService = + client.getService(CalculatorService.class, "CalculatorServiceComponentA"); + + } catch(Exception ex){ + System.err.println(ex.toString()); + } + + } + + @AfterClass + public static void destroy() throws Exception { + nodeC.stop(); + nodeB.stop(); + nodeA.stop(); + manager.stop(); + } + + @Test + public void testCalculator() throws Exception { + + // Calculate + Assert.assertEquals(calculatorService.add(3, 2), 5.0); + Assert.assertEquals(calculatorService.subtract(3, 2), 1.0); + Assert.assertEquals(calculatorService.multiply(3, 2), 6.0); + Assert.assertEquals(calculatorService.divide(3, 2), 1.5); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/workspace.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/workspace.xml new file mode 100644 index 0000000000..7d6d3dbdbd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-distributed/workspace.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/README b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/README new file mode 100644 index 0000000000..bd66eee1c9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/README @@ -0,0 +1,266 @@ +Calculator Implementation Policies Sample +========================================= +This sample builds over simple calculator sample to demonstrate how Implementation Policies can +be use in Tuscany SCA Java. + +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 the sample 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 the calculator service with a default SCA (java) binding. The 'logging' policy +which is handled by the Tuscany SCA java policy-logging module is used in this calculator +composite to specify the need for 'logging'. The MultiplyService Component specifies for 'jassAuthentication' +which is one way of implemention login authentication, using the Java Authentication and Authorization Service. + +The logging intent and policyset that is to be used by this calculator application must be +defined in the definitions.xml file. Here we use the policyset structure already defined in +Tuscany for logging under the policy-logging and hence there is no need to specify the policyset processors +and policy handler classes as part of this application. + +Similarly the jaasAuthentication intent and policyset also is defined in the definitions.xml file +of this sample. This sample uses the calculator.security.JaasLoginModule class for handling the +authentication functions. Right now there is a simply matching of userid and passwords that happens in this +class. Applications could implement their own sophisticated authentication mechanisms. For more information +on how to do this please look up Java Authentication and Authorization Service documentation. The sample +also use the calculator.security.CalculatorCallbackHandler to fetch the userid and password to be use for the +login authentication. This handler presently uses hardcoded userids and passwords. Applications could +typically use this handler to prompt for userid and passwords. + +There are two components that provide the calculator service namely 'CalculatorServiceComponent' +and 'AnotherCalculatorServiceComponent'. The logging intent is specified for the 'subtract' and 'divide' +operations of the 'CalculatorServiceCompnent' implementation, and on the entire implementation +(i.e. all operations) for the AddServiceComponent and AnotherCalculatorServiceComponent. + +The CalculatorClient first exercises the CalculatorServiceComponent calling add, +subtract, multiply and divide operations. This results in logging messages appearing on the +console for 'add', 'subtract' and 'divide' operations. The CalculatorClient then exercises the +AnotherCalculatorServiceComponent calling all the service methods. This will result in logging messages +printed on the console for all the operations. For the 'add' operation there will be two sets of messages +printed - one that has resulted from specifying the 'logging' intent on the implementation element of the +'AnotherCalculatorServiceComponent' and another from specifying the 'logging' intent on the +'AddServiceComponent' + +The jaasAuthentication intent is specified for the 'MultiplyServiceComponent'. So everytime this component +is invoke an authentication is attempted and only if it succeeds, is the multiply function is invoked. The +console prints messages that denote if the authentication has succeeded or failed. + +Thus this sample demonstrates how intents could be applied to either implementations as a whole or to some +selective operations on an implementation. + + +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 + calculator/security + JaasLoginModule.java JaasLoginModule implementation for this sample + CalculatorCallbackHandler.java JAAS callbackhandler for fetching userid and password + + + resources/ + Calculator.composite - the SCA assembly for this sample + definitions.xml - sca definitions file that defines the 'logging' intent + and policyset + used by this application + CalculatorLogMessages.properties - A resource bundle contain the log messages to be + used. + CalculatorJaas.config - JAAS Login Configuration file + + 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-implementation-policies +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] Calling CalculatorServiceComponent configured with 'logging' policy for subtract and divide operations... + [java] Nov 23, 2007 1:06:10 PM + [java] INFO: Invoking operation - add + [java] Nov 23, 2007 1:06:10 PM + [java] INFO: Returned from operation - add + [java] 3 + 2=5.0 + [java] 3 - 2=1.0 + [java] 3 * 2=6.0 + [java] 3 / 2=1.5 + [java] Calling CalculatorServiceComponent configured with 'logging' for all operations in the implementation... + [java] Nov 23, 2007 1:06:10 PM + [java] INFO: Invoking operation - subtract + [java] Nov 23, 2007 1:06:10 PM + [java] INFO: Returned from operation - subtract + [java] Nov 23, 2007 1:06:10 PM + [java] INFO: Invoking operation - divide + [java] Nov 23, 2007 1:06:10 PM + [java] INFO: Returned from operation - divide + [java] Nov 23, 2007 1:06:10 PM + [java] 3 + 2=5.0 + [java] 3 - 2=1.0 + [java] 3 * 2=6.0 + [java] INFO: Invoking operation - add + [java] 3 / 2=1.5 + [java] Nov 23, 2007 1:06:10 PM + [java] INFO: Invoking operation - add + [java] Nov 23, 2007 1:06:10 PM + [java] INFO: Returned from operation - add + [java] Nov 23, 2007 1:06:10 PM + [java] INFO: Returned from operation - add + [java] Nov 23, 2007 1:06:10 PM + [java] INFO: Invoking operation - subtract + [java] Nov 23, 2007 1:06:10 PM + [java] INFO: Returned from operation - subtract + [java] Nov 23, 2007 1:06:10 PM + [java] INFO: Invoking operation - multiply + [java] Nov 23, 2007 1:06:10 PM + [java] INFO: Returned from operation - multiply + [java] Nov 23, 2007 1:06:10 PM + [java] INFO: Invoking operation - divide + [java] Nov 23, 2007 1:06:10 PM + [java] INFO: Returned from operation - divide + +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. Notice the log messages. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running calculator.CalculatorTestCase +Dec 18, 2007 12:05:06 PM org.apache.tuscany.sca.contribution.processor.ValidatingXMLStreamReader$1 error +WARNING: XMLSchema validation problem in: file:/F:/LatestTrunk/sca/samples/calculator-implementation-policies/target/ +classes/Calculator.composite, line: 28, column: 4 +cvc-complex-type.2.4.a: Invalid content was found starting with element 'operation'. One of '{WC[##other:"http://www. +osoa.org/xmlns/sca/1.0"]}' is expected. +Dec 18, 2007 12:05:06 PM +INFO: Invoking operation - add +Dec 18, 2007 12:05:06 PM +FINER: Inovoking operation add with arguments 3.0, 2.0, +Dec 18, 2007 12:05:06 PM +INFO: Returned from operation - add +Dec 18, 2007 12:05:06 PM +FINER: Returning from operation add with return value 5 +Dec 18, 2007 12:05:06 PM +INFO: Invoking operation - subtract +Dec 18, 2007 12:05:06 PM +FINER: Inovoking operation subtract with arguments 3.0, 2.0, +Dec 18, 2007 12:05:06 PM +INFO: Returned from operation - subtract +Dec 18, 2007 12:05:06 PM +FINER: Returning from operation subtract with return value 1 +Successfully AUTHENTICATED!! +Dec 18, 2007 12:05:06 PM +INFO: Invoking operation - divide +Dec 18, 2007 12:05:06 PM +FINER: Inovoking operation divide with arguments 3.0, 2.0, +Dec 18, 2007 12:05:06 PM +INFO: Returned from operation - divide +Dec 18, 2007 12:05:06 PM +FINER: Returning from operation divide with return value 1.5 +Dec 18, 2007 12:05:06 PM org.apache.tuscany.sca.contribution.processor.ValidatingXMLStreamReader$1 error +WARNING: XMLSchema validation problem in: file:/F:/LatestTrunk/sca/samples/calculator-implementation-policies/target/ +classes/Calculator.composite, line: 28, column: 4 +cvc-complex-type.2.4.a: Invalid content was found starting with element 'operation'. One of '{WC[##other:"http://www. +osoa.org/xmlns/sca/1.0"]}' is expected. +Dec 18, 2007 12:05:06 PM +INFO: Invoking operation - add +Dec 18, 2007 12:05:06 PM +FINER: Inovoking operation add with arguments 3.0, 2.0, +Dec 18, 2007 12:05:06 PM +INFO: Invoking operation - add +Dec 18, 2007 12:05:06 PM +FINER: Inovoking operation add with arguments 3.0, 2.0, +Dec 18, 2007 12:05:06 PM +INFO: Returned from operation - add +Dec 18, 2007 12:05:06 PM +FINER: Returning from operation add with return value 5 +Dec 18, 2007 12:05:06 PM +INFO: Returned from operation - add +Dec 18, 2007 12:05:06 PM +FINER: Returning from operation add with return value 5 +Dec 18, 2007 12:05:06 PM +INFO: Invoking operation - subtract +Dec 18, 2007 12:05:06 PM +FINER: Inovoking operation subtract with arguments 3.0, 2.0, +Dec 18, 2007 12:05:06 PM +INFO: Returned from operation - subtract +Dec 18, 2007 12:05:06 PM +FINER: Returning from operation subtract with return value 1 +Dec 18, 2007 12:05:06 PM +INFO: Invoking operation - multiply +Dec 18, 2007 12:05:06 PM +FINER: Inovoking operation multiply with arguments 3.0, 2.0, +Successfully AUTHENTICATED!! +Dec 18, 2007 12:05:06 PM +INFO: Returned from operation - multiply +Dec 18, 2007 12:05:06 PM +FINER: Returning from operation multiply with return value 6 +Dec 18, 2007 12:05:06 PM +INFO: Invoking operation - divide +Dec 18, 2007 12:05:06 PM +FINER: Inovoking operation divide with arguments 3.0, 2.0, +Dec 18, 2007 12:05:06 PM +INFO: Returned from operation - divide +Dec 18, 2007 12:05:06 PM +FINER: Returning from operation divide with return value 1.5 +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.823 sec + +Results : + +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 + +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-20080910/samples/calculator-implementation-policies/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/build.xml new file mode 100644 index 0000000000..7afa23a07f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/calculator.png b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/calculator.png new file mode 100644 index 0000000000..995a57b1fd Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/calculator.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/calculator.svg b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/calculator.svg new file mode 100644 index 0000000000..af34f07e04 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/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-20080910/samples/calculator-implementation-policies/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/pom.xml new file mode 100644 index 0000000000..e5ccc076a5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-calculator-impl-policies + Apache Tuscany SCA Calculator Sample using Implementation Policies + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + org.apache.tuscany.sca + tuscany-policy-logging + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-policy-security + 1.4-SNAPSHOT + runtime + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..5a1e7a638a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/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-20080910/samples/calculator-implementation-policies/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..caf4d358df --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Adding " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..2bce187049 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import javax.security.auth.login.Configuration; + +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 { + try { + Configuration secConf = Configuration.getConfiguration(); + } catch (java.lang.SecurityException e) { + System.setProperty("java.security.auth.login.config", CalculatorClient.class.getClassLoader() + .getResource("CalculatorJass.config").toString()); + } + + SCADomain scaDomain = SCADomain.newInstance("Calculator.composite"); + + CalculatorService calculatorService = + scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent"); + + // Calculate + System.out.println("Calling CalculatorServiceComponent configured with 'logging' " + + "policy for subtract and divide operations..."); + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + + calculatorService = + scaDomain.getService(CalculatorService.class, "AnotherCalculatorServiceComponent"); + + // Calculate + System.out.println("Calling CalculatorServiceComponent configured with 'logging' " + + "for all operations in the implementation..."); + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + + scaDomain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..ad87375529 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/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-20080910/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..ae4ed12b7b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/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-20080910/samples/calculator-implementation-policies/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..ef6a8b375b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/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-20080910/samples/calculator-implementation-policies/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..cd91935f08 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2); + return n1 / n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/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-20080910/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..c85357fcd8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2); + return n1 * n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..56ee372fc4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/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-20080910/samples/calculator-implementation-policies/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1b669084d9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2); + return n1 - n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/security/CalculatorCallbackHandler.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/security/CalculatorCallbackHandler.java new file mode 100644 index 0000000000..b48fb90148 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/security/CalculatorCallbackHandler.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator.security; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.NameCallback; +import javax.security.auth.callback.PasswordCallback; +import javax.security.auth.callback.UnsupportedCallbackException; + +/** + * @version $Rev$ $Date$ + */ +public class CalculatorCallbackHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + if (callbacks[i] instanceof NameCallback) { + NameCallback nc = (NameCallback)callbacks[i]; + nc.setName("CalculatorUser"); + } else if (callbacks[i] instanceof PasswordCallback) { + PasswordCallback pc = (PasswordCallback)callbacks[i]; + pc.setPassword("CalculatorUserPasswd".toCharArray()); + } else { + throw new UnsupportedCallbackException + (callbacks[i], "Unsupported Callback!"); + } + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/security/JaasLoginModule.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/security/JaasLoginModule.java new file mode 100644 index 0000000000..fe4097640b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/security/JaasLoginModule.java @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator.security; + +import java.security.Principal; +import java.util.Map; + +import javax.security.auth.Subject; +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.NameCallback; +import javax.security.auth.callback.PasswordCallback; +import javax.security.auth.login.LoginException; +import javax.security.auth.spi.LoginModule; + +/** + * @version $Rev$ $Date$ + */ +public class JaasLoginModule implements LoginModule { + + private CallbackHandler callbackHandler; + private Subject subject; + private Principal userPrincipal; + private String userId; + private String password; + private boolean succeeded; + private boolean commitSucceeded; + + public void initialize(Subject subject, + CallbackHandler callbackHandler, + Map sharedState, + Map options) { + this.callbackHandler = callbackHandler; + this.subject = subject; + } + + public boolean login() throws LoginException { + Callback[] callbacks = new Callback[2]; + callbacks[0] = new NameCallback("UserId:"); + callbacks[1] = new PasswordCallback("Password:", false); + + try { + callbackHandler.handle(callbacks); + userId = ((NameCallback)callbacks[0]).getName(); + password = new String(((PasswordCallback)callbacks[1]).getPassword()); + + if (userId.equals("CalculatorUser") && password.equals("CalculatorUserPasswd")) { + System.out.println("Successfully AUTHENTICATED!!"); + succeeded = true; + return true; + } else { + System.out.println("Incorrect userId / password! AUTHENTICATION FAILED!!"); + return false; + } + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + *

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

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

+ * + * @exception LoginException if the commit fails. + * + * @return true if this LoginModule's own login and commit + * attempts succeeded, or false otherwise. + */ + public boolean commit() throws LoginException { + if (succeeded == false) { + return false; + } else { + // add a Principal (authenticated identity) to the Subject + + // assume the user we authenticated is the UserPrincipal + userPrincipal = new UserPrincipal(userId); + if (!subject.getPrincipals().contains(userPrincipal)) + subject.getPrincipals().add(userPrincipal); + + // in any case, clean out state + userId = null; + password = null; + commitSucceeded = true; + return true; + } + } + + /** + *

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

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

+ * + * @exception LoginException if the abort fails. + * + * @return false if this LoginModule's own login and/or commit attempts + * failed, and true otherwise. + */ + public boolean abort() throws LoginException { + if (succeeded == false) { + return false; + } else if (succeeded == true && commitSucceeded == false) { + // login succeeded but overall authentication failed + succeeded = false; + userId = null; + password = null; + userPrincipal = null; + } else { + // overall authentication succeeded and commit succeeded, + // but someone else's commit failed + logout(); + } + return true; + } + + /** + * Logout the user. + * + *

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

+ * + * @exception LoginException if the logout fails. + * + * @return true in all cases since this LoginModule + * should not be ignored. + */ + public boolean logout() throws LoginException { + subject.getPrincipals().remove(userPrincipal); + succeeded = false; + succeeded = commitSucceeded; + userId = null; + if (password != null) + password = null; + userPrincipal = null; + return true; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/security/UserPrincipal.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/security/UserPrincipal.java new file mode 100644 index 0000000000..595626e672 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/java/calculator/security/UserPrincipal.java @@ -0,0 +1,66 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package calculator.security; + +import java.security.Principal; + +/** + * @version $Rev$ $Date$ + */ +public class UserPrincipal implements Principal { + + private final String name; + + public UserPrincipal(String name) { + if (name == null) + throw new IllegalArgumentException("name cannot be null"); + this.name = name; + } + + public String getName() { + return name; + } + + public String toString() { + return name; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final UserPrincipal other = (UserPrincipal)obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/Calculator.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..d91bf88d96 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/Calculator.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/CalculatorJass.config b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/CalculatorJass.config new file mode 100644 index 0000000000..0e7cb86633 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/CalculatorJass.config @@ -0,0 +1,3 @@ +Calculator { + calculator.security.JaasLoginModule required debug=true; +}; diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/CalculatorLogMessages.properties b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/CalculatorLogMessages.properties new file mode 100644 index 0000000000..f62125eaa9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/CalculatorLogMessages.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +CALLING_OPERATION=Inovoking operation {0} with arguments {1} +OPERATION_RETURNED=Returning from operation {0} with return value {1} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/definitions.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/definitions.xml new file mode 100644 index 0000000000..6cccde0d13 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/main/resources/definitions.xml @@ -0,0 +1,40 @@ + + + + + + + + Calculator + calculator.security.CalculatorCallbackHandler + + + + + + + FINER + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/test/java/calculator/CalculatorTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..157570c3df --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-implementation-policies/src/test/java/calculator/CalculatorTestCase.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 javax.security.auth.login.Configuration; + +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 CalculatorService anotherCalculatorService; + private SCADomain scaDomain; + + @Override + protected void setUp() throws Exception { + try { + Configuration secConf = Configuration.getConfiguration(); + } catch ( java.lang.SecurityException e ) { + //FIXME: We should not compare exception strings as they are localized in various languages + //if ( e.getMessage().equals("Unable to locate a login configuration") ) { + System.setProperty("java.security.auth.login.config", + this.getClass().getClassLoader().getResource("CalculatorJass.config").toString()); + //} else { + // throw e; + //} + } + scaDomain = SCADomain.newInstance("Calculator.composite"); + calculatorService = scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent"); + anotherCalculatorService = scaDomain.getService(CalculatorService.class, "AnotherCalculatorServiceComponent"); + } + + @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); + } + + public void testAnotherCalculator() throws Exception { + // Calculate + assertEquals(anotherCalculatorService.add(3, 2), 5.0); + assertEquals(anotherCalculatorService.subtract(3, 2), 1.0); + assertEquals(anotherCalculatorService.multiply(3, 2), 6.0); + assertEquals(anotherCalculatorService.divide(3, 2), 1.5); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/README b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/README new file mode 100644 index 0000000000..a8aff232c6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/README @@ -0,0 +1,87 @@ +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: + +java -jar /modules/tuscany-node-launcher.jar Calculator.composite target/sample-calculator-lean.jar + +Sample Overview +--------------- +The sample provides a single calculator service with a default SCA (java) +binding. The CalculatorClient exercises this interface by calling add, +subtract, multiply and divide operations. This results in messages passing to +the appropriate components in the composite across the local wires. + +calculator/ + src/ + main/ + java/ + calculator/ + CalculatorService.java - the first component, calls +-/* as + appropriate + CalculatorServiceImpl.java + AddService.java - adds two numbers + AddServiceImpl.java + SubtractService.java - subtracts one number from another + SubtractServiceImpl.java + MultiplyService.java - multiplies two numbers + MultiplyServiceImpl.java + DivideService.java - divides one number by another + DivideServiceImpl.java + CalculatorClient.java - a client component that calls the + Calculator 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-20080910/samples/calculator-lean/calculator.png b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/calculator.png new file mode 100644 index 0000000000..995a57b1fd Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/calculator.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/calculator.svg b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/calculator.svg new file mode 100644 index 0000000000..0615925c50 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/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-20080910/samples/calculator-lean/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/pom.xml new file mode 100644 index 0000000000..10f4ae110f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/pom.xml @@ -0,0 +1,71 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-calculator-lean + Apache Tuscany SCA Calculator Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..188451ebac --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/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-20080910/samples/calculator-lean/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..7ca8fb04b5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Adding " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..2bb8f96dcf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/CalculatorClient.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 calculator; + +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +@Scope("COMPOSITE") @EagerInit +public class CalculatorClient { + + private CalculatorService calculatorService; + + @Reference + public void setCalculatorService(CalculatorService calculatorService) { + this.calculatorService = calculatorService; + } + + @Init + public void calculate() { + + // Calculate + System.out.println("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-20080910/samples/calculator-lean/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..031fa8b912 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/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-20080910/samples/calculator-lean/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..3d861f2018 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/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-20080910/samples/calculator-lean/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/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-20080910/samples/calculator-lean/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..1323edf55a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2); + return n1 / n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/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-20080910/samples/calculator-lean/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..91b803bc9e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2); + return n1 * n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..bf0d1882b6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/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-20080910/samples/calculator-lean/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..58cc4a3547 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2); + return n1 - n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/resources/Calculator.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..913081b9be --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/resources/Calculator.composite @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/resources/CalculatorTest.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/resources/CalculatorTest.composite new file mode 100644 index 0000000000..906e2a3918 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/main/resources/CalculatorTest.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/test/java/calculator/CalculatorTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..a007a28f21 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-lean/src/test/java/calculator/CalculatorTestCase.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +/** + * This shows how to test the Calculator composition. + */ +@Scope("COMPOSITE") @EagerInit +public class CalculatorTestCase extends TestCase { + + private static CalculatorService calculatorService; + private SCANode node; + + @Reference + public void setCalculatorService(CalculatorService calculatorService) { + CalculatorTestCase.calculatorService = calculatorService; + } + + @Override + protected void setUp() throws Exception { + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANodeFromClassLoader("CalculatorTest.composite", getClass().getClassLoader()); + node.start(); + } + + @Override + protected void tearDown() throws Exception { + node.stop(); + } + + 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-20080910/samples/calculator-osgi/README b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/README new file mode 100644 index 0000000000..cde5fe981f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/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-20080910/samples/calculator-osgi/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/build.xml new file mode 100644 index 0000000000..c4b755ef94 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/calculator.png b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/calculator.png new file mode 100644 index 0000000000..995a57b1fd Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/calculator.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/calculator.svg b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/calculator.svg new file mode 100644 index 0000000000..af34f07e04 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/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-20080910/samples/calculator-osgi/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/pom.xml new file mode 100644 index 0000000000..a1d371df73 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/pom.xml @@ -0,0 +1,99 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-calculator-osgi + Apache Tuscany SCA Calculator OSGi Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-node-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-extensibility-equinox + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-node-launcher-equinox + 1.4-SNAPSHOT + compile + + + + javax.servlet + servlet-api + 2.5 + provided + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..188451ebac --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/AddService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The Add service interface + */ +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..7ca8fb04b5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Adding " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..c193b2ce66 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +@Scope("COMPOSITE") @EagerInit +public class CalculatorClient { + + private CalculatorService calculatorService; + + @Reference + public void setCalculatorService(CalculatorService calculatorService) { + this.calculatorService = calculatorService; + } + + @Init + public void calculate() { + + // Calculate + System.out.println("SCA API ClassLoader: " + print(Reference.class.getClassLoader())); + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + } + + private static String print(ClassLoader cl) { + StringBuffer buf = new StringBuffer(); + for (; cl != null;) { + buf.append(cl.toString()); + buf.append(' '); + cl = cl.getParent(); + } + return buf.toString(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..031fa8b912 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/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-20080910/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..3d861f2018 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/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-20080910/samples/calculator-osgi/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/DivideService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The divide service interface + */ +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..1323edf55a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2); + return n1 / n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..91b803bc9e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2); + return n1 * n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..bf0d1882b6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/SubtractService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..58cc4a3547 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2); + return n1 - n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/resources/Calculator.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..913081b9be --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/main/resources/Calculator.composite @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..dc0da7d20d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.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 calculator; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher; +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Scope; + +/** + * This shows how to test the Calculator composition. + */ +@Scope("COMPOSITE") +@EagerInit +public class CalculatorTestCase extends TestCase { + + private NodeLauncher launcher; + private SCANode node; + + @Override + protected void setUp() throws Exception { + launcher = NodeLauncher.newInstance(); + node = launcher.createNodeFromClassLoader("Calculator.composite", getClass().getClassLoader()); + System.out.println("SCA Node API ClassLoader: " + node.getClass().getClassLoader()); + node.start(); + } + + @Override + protected void tearDown() throws Exception { + if (launcher != null) { + node.stop(); + launcher.destroy(); + } + } + + public void testDummy() { + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/META-INF/MANIFEST.MF b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..57ecdff710 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/META-INF/MANIFEST.MF @@ -0,0 +1,25 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Apache Tuscany SCA Calculator RCP Sample +Bundle-SymbolicName: sample.calculator.rcp;singleton:=true +Bundle-Version: 1.4.0.SNAPSHOT +Bundle-Activator: calculator.rcp.Activator +Bundle-Vendor: The Apache Software Foundation +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-ActivationPolicy: lazy +Import-Package: org.osoa.sca;version="1.4.0", + org.osoa.sca.annotations;version="1.4.0" +Bundle-ClassPath: ., + cglib-nodep-2.1_3.jar, + jaxb-impl-2.1.7.jar, + activation-1.1.jar, + jsr250-api-1.0.jar, + jsr181-api-1.0-MR1.jar, + jaxb-api-2.1.jar, + stax-api-1.0-2.jar, + jaxws-api-2.1.jar, + geronimo-commonj_1.1_spec-1.0.jar, + XmlSchema-1.3.2.jar, + wstx-asl-3.2.1.jar diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/build.properties b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/build.properties new file mode 100644 index 0000000000..0530eb648b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/build.properties @@ -0,0 +1,5 @@ +source.. = src/main/java/ +output.. = target/classes/ +bin.includes = plugin.xml,\ + META-INF/,\ + . diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/icons/alt_window_16.gif b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/icons/alt_window_16.gif new file mode 100644 index 0000000000..05626b17d8 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/icons/alt_window_16.gif differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/icons/alt_window_32.gif b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/icons/alt_window_32.gif new file mode 100644 index 0000000000..b432f88339 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/icons/alt_window_32.gif differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/plugin.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/plugin.xml new file mode 100644 index 0000000000..1fb5acd9b5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/plugin.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/pom.xml new file mode 100644 index 0000000000..a487076de6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/pom.xml @@ -0,0 +1,126 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample.calculator.rcp + Apache Tuscany SCA Calculator RCP Sample + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-node-impl + 1.4-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-implementation-node-runtime + 1.4-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-extensibility-equinox + 1.4-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-node-launcher-equinox + 1.4-SNAPSHOT + compile + + + + javax.servlet + servlet-api + 2.5 + provided + + + junit + junit + 4.2 + test + + + + ${artifactId} + + + maven-eclipse-plugin + 2.5.1 + + + org.eclipse.pde.ManifestBuilder + org.eclipse.jdt.core.javabuilder + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + + org.eclipse.jdt.launching.JRE_CONTAINER + + org.eclipse.pde.core.requiredPlugins + + + + + + maven-jar-plugin + + + ${basedir}/META-INF/MANIFEST.MF + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/Calculator.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/Calculator.composite new file mode 100644 index 0000000000..913081b9be --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/Calculator.composite @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..188451ebac --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/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-20080910/samples/calculator-rcp/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..7ca8fb04b5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Adding " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..adbd18a9e4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +@Scope("COMPOSITE") +@EagerInit +public class CalculatorClient { + + private CalculatorService calculatorService; + + @Reference + public void setCalculatorService(CalculatorService calculatorService) { + this.calculatorService = calculatorService; + } + + @Init + public void calculate() { + // Calculate + System.out.println("SCA API ClassLoader: " + Reference.class.getClassLoader()); + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..c89043276e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/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-20080910/samples/calculator-rcp/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..ba897fa301 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/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-20080910/samples/calculator-rcp/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/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-20080910/samples/calculator-rcp/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..1323edf55a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2); + return n1 / n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/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-20080910/samples/calculator-rcp/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..91b803bc9e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2); + return n1 * n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..bf0d1882b6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/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-20080910/samples/calculator-rcp/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..58cc4a3547 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2); + return n1 - n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java new file mode 100644 index 0000000000..1dcf5b4e88 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator.rcp; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.apache.tuscany.sca.sample.calculator.rcp"; + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/Application.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/Application.java new file mode 100644 index 0000000000..5ce6522fed --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/Application.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator.rcp; + +import org.eclipse.equinox.app.IApplication; +import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; + +/** + * This class controls all aspects of the application's execution + */ +public class Application implements IApplication { + + /* (non-Javadoc) + * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) + */ + public Object start(IApplicationContext context) { + Display display = PlatformUI.createDisplay(); + try { + int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); + if (returnCode == PlatformUI.RETURN_RESTART) { + return IApplication.EXIT_RESTART; + } + return IApplication.EXIT_OK; + } finally { + display.dispose(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.equinox.app.IApplication#stop() + */ + public void stop() { + final IWorkbench workbench = PlatformUI.getWorkbench(); + if (workbench == null) + return; + final Display display = workbench.getDisplay(); + display.syncExec(new Runnable() { + public void run() { + if (!display.isDisposed()) + workbench.close(); + } + }); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationActionBarAdvisor.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationActionBarAdvisor.java new file mode 100644 index 0000000000..2fccfb2d77 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationActionBarAdvisor.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator.rcp; + +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; + +/** + * An action bar advisor is responsible for creating, adding, and disposing of + * the actions added to a workbench window. Each window will be populated with + * new actions. + */ +public class ApplicationActionBarAdvisor extends ActionBarAdvisor { + + // Actions - important to allocate these only in makeActions, and then use + // them + // in the fill methods. This ensures that the actions aren't recreated + // when fillActionBars is called with FILL_PROXY. + private IWorkbenchAction exitAction; + + public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { + super(configurer); + } + + protected void makeActions(final IWorkbenchWindow window) { + // Creates the actions and registers them. + // Registering is needed to ensure that key bindings work. + // The corresponding commands keybindings are defined in the plugin.xml + // file. + // Registering also provides automatic disposal of the actions when + // the window is closed. + + exitAction = ActionFactory.QUIT.create(window); + register(exitAction); + } + + protected void fillMenuBar(IMenuManager menuBar) { + MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE); + menuBar.add(fileMenu); + fileMenu.add(exitAction); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchAdvisor.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchAdvisor.java new file mode 100644 index 0000000000..ac1893509c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchAdvisor.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator.rcp; + +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchAdvisor; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; + +public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { + + private static final String PERSPECTIVE_ID = "org.apache.tuscany.sca.sample.calculator.rcp.perspective"; + + public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + return new ApplicationWorkbenchWindowAdvisor(configurer); + } + + public String getInitialWindowPerspectiveId() { + return PERSPECTIVE_ID; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchWindowAdvisor.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchWindowAdvisor.java new file mode 100644 index 0000000000..6378decf20 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchWindowAdvisor.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.rcp; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; + +public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { + + public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + super(configurer); + } + + public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { + return new ApplicationActionBarAdvisor(configurer); + } + + public void preWindowOpen() { + IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); + configurer.setInitialSize(new Point(400, 300)); + configurer.setShowCoolBar(false); + configurer.setShowStatusLine(false); + configurer.setTitle("Tuscany SCA Calculator RCP Application"); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/Perspective.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/Perspective.java new file mode 100644 index 0000000000..445b4b65b2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/Perspective.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.rcp; + +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IPerspectiveFactory; + +public class Perspective implements IPerspectiveFactory { + + public void createInitialLayout(IPageLayout layout) { + String editorArea = layout.getEditorArea(); + layout.setEditorAreaVisible(false); + layout.setFixed(true); + + layout.addStandaloneView(View.ID, false, IPageLayout.LEFT, 1.0f, editorArea); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/View.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/View.java new file mode 100644 index 0000000000..f95c1e029c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rcp/src/main/java/calculator/rcp/View.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator.rcp; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.ViewPart; + +public class View extends ViewPart { + public static final String ID = "org.apache.tuscany.sca.sample.calculator.rcp.view"; + + private TableViewer viewer; + + /** + * The content provider class is responsible for providing objects to the + * view. It can wrap existing objects in adapters or simply return objects + * as-is. These objects may be sensitive to the current input of the view, + * or ignore it and always show the same content (like Task List, for + * example). + */ + class ViewContentProvider implements IStructuredContentProvider { + public void inputChanged(Viewer v, Object oldInput, Object newInput) { + } + + public void dispose() { + } + + public Object[] getElements(Object parent) { + return new String[] {"One", "Two", "Three"}; + } + } + + class ViewLabelProvider extends LabelProvider implements ITableLabelProvider { + public String getColumnText(Object obj, int index) { + return getText(obj); + } + + public Image getColumnImage(Object obj, int index) { + return getImage(obj); + } + + public Image getImage(Object obj) { + return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT); + } + } + + /** + * This is a callback that will allow us to create the viewer and initialize + * it. + */ + public void createPartControl(Composite parent) { + viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); + viewer.setContentProvider(new ViewContentProvider()); + viewer.setLabelProvider(new ViewLabelProvider()); + viewer.setInput(getViewSite()); + } + + /** + * Passing the focus request to the viewer's control. + */ + public void setFocus() { + viewer.getControl().setFocus(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/README b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/README new file mode 100644 index 0000000000..837b5ce75f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-rmi-reference/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/build.xml new file mode 100644 index 0000000000..ca75625b42 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/calculator-rmi-reference.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-rmi-reference/calculator-rmi-reference.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/calculator-rmi-reference.svg b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-reference/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/pom.xml new file mode 100644 index 0000000000..452662e7aa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/pom.xml @@ -0,0 +1,68 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-calculator-rmi-reference + Apache Tuscany SCA Calculator RMI Reference Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-binding-rmi + 1.4-SNAPSHOT + runtime + + + junit + junit + 4.2 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-service/README b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/README new file mode 100644 index 0000000000..454cdc0d37 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-rmi-service/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/build.xml new file mode 100644 index 0000000000..f98f35e4b0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/calculator-rmi-service.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-rmi-service/calculator-rmi-service.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/calculator-rmi-service.svg b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-service/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/pom.xml new file mode 100644 index 0000000000..5294cced21 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/pom.xml @@ -0,0 +1,68 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-calculator-rmi-service + Apache Tuscany SCA Calculator RMI Service Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-binding-rmi + 1.4-SNAPSHOT + runtime + + + junit + junit + 4.2 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite new file mode 100644 index 0000000000..34d90ab451 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-script/README b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/README new file mode 100644 index 0000000000..ab1dda13df --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-script/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/build.xml new file mode 100644 index 0000000000..429d638ca5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/calculator-script.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-script/calculator-script.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/calculator-script.svg b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/calculator-script.svg new file mode 100644 index 0000000000..16939f9310 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-script/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/pom.xml new file mode 100644 index 0000000000..bbc430875a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-calculator-script + Apache Tuscany SCA Calculator Sample using Scripting Languages + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-script + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-interface-wsdl-xml + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-script/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-script/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-script/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-script/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-script/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-script/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-script/src/main/resources/Calculator.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-script/src/main/resources/Calculator.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-script/src/main/resources/calculator/AddServiceImpl.js b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-script/src/main/resources/calculator/DivideServiceImpl.groovy b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-script/src/main/resources/calculator/MultiplyServiceImpl.py b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-script/src/main/resources/calculator/SubtractServiceImpl.rb b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-script/src/test/java/calculator/CalculatorTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-webapp/README b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/README new file mode 100644 index 0000000000..c88b92b206 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-webapp/calculator-web.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-webapp/calculator-web.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/calculator-web.svg b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/calculator-web.svg new file mode 100644 index 0000000000..00ed27556f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-webapp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/pom.xml new file mode 100644 index 0000000000..cccbd6aefa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/pom.xml @@ -0,0 +1,95 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-calculator-webapp + war + Apache Tuscany SCA Calculator Sample in a WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + generate + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-webapp/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-webapp/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-webapp/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-webapp/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-webapp/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-webapp/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-webapp/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-webapp/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-webapp/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-webapp/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-webapp/src/main/resources/Calculator.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator-webapp/src/main/resources/Calculator.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..b5a828d55b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + + + Apache Tuscany Calculator Web Service Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + calc.jsp + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/webapp/calc.jsp b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/webapp/calc.jsp new file mode 100644 index 0000000000..4bc5c984dd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-webapp/src/main/webapp/calc.jsp @@ -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. +--%> + +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib uri="http://www.osoa.org/sca/sca_jsp.tld" prefix="sca" %> + + + + +Calculator sample + + + + + + + + + + + + + + + + + + +
ExpressionResult
2 + 3<%= CalculatorServiceComponent.add(2, 3) %>
3 - 2<%= CalculatorServiceComponent.subtract(3, 2) %>
3 * 2<%= CalculatorServiceComponent.multiply(3, 2) %>
3 / 2<%= CalculatorServiceComponent.divide(3, 2) %>
+ + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/README b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/README new file mode 100644 index 0000000000..a6e6c897e4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/README @@ -0,0 +1,108 @@ +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-ws-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-ws-webapp + +The sample is configured to use a service on port 8080. If your servlet container +is using a port other than 8080 then you will need to edit the Calculator.composite +and change the uri attribute of the used by the CalculatorServiceComponent +to use the correct port. + +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. + +calculator-webapp/ + src/ + main/ + java/ + calculator/ + AddService.java - As calculator sample + AddServiceImpl.java + CalculatorClient.java - As calculator sample + CalculatorService.java - As calculator sample + CalculatorServiceImpl.java + DivideService.java - As calculator sample + DivideServiceImpl.java + MultiplyService.java - As calculator sample + MultiplyServiceImpl.java + SubtractService.java - As calculator sample + SubtractServiceImpl.java + 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 + + calculator.png - a pictorial representation of the sample .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + README - this file + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built using Ant as +follows + +cd calculator-ws-webapp +ant package + +This should result in a war file (sample-calculator-ws-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-ws-webapp + +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-ws-webapp +mvn + +Again this should result in a war file (sample-calculator-ws-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-20080910/samples/calculator-ws-secure-webapp/calculator-web.png b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/calculator-web.png new file mode 100644 index 0000000000..f482b8d1c8 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/calculator-web.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/calculator-web.svg b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/calculator-web.svg new file mode 100644 index 0000000000..1b7015b156 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/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-20080910/samples/calculator-ws-secure-webapp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/pom.xml new file mode 100644 index 0000000000..5b506ee96c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/pom.xml @@ -0,0 +1,102 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-calculator-ws-secure-webapp + war + Apache Tuscany SCA Calculator Sample Web Service enabled for +WS Security and in a WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + generate + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..c3c789e745 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/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-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..46ec182124 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import 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); + System.err.println("Adding " + n1 + " to " + n2); + return n1 + n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..4787b728f4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-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-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..ad87375529 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-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-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..bf3b0303ec --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-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-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..835e4fda6d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-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-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..8c33862f6d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-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-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-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-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..c7fbc73c00 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-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-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..c8653806aa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/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 subtract service + */ +@Remotable +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1a7f145ad8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-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-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/security/ClientPWCBHandler.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/security/ClientPWCBHandler.java new file mode 100644 index 0000000000..9625c0d692 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/security/ClientPWCBHandler.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 calculator.security; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + */ +public class ClientPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Client UserId/Password Handler .... "); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + System.out.println("User Id = " + pwcb.getIdentifer()); + System.out.println("Set Password = " + pwcb.getPassword()); + System.out.println("Usage = " + pwcb.getUsage()); + if ( pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN ) { + if ( pwcb.getIdentifer().equals("CalculatorUser")){ + pwcb.setPassword("CalculatorUserPasswd"); + } else { + throw new UnsupportedCallbackException(pwcb, "Authentication Failed : UserId - Password mismatch"); + } + } else if ( pwcb.getUsage() == WSPasswordCallback.SIGNATURE ) { + if ( pwcb.getIdentifer().equals("CalculatorUser")) { + pwcb.setPassword("CalculatorUserPasswd"); + } else { + pwcb.setPassword("CalculatorAdmin"); + } + } + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/security/ServerPWCBHandler.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/security/ServerPWCBHandler.java new file mode 100644 index 0000000000..23a62680c5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/java/calculator/security/ServerPWCBHandler.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 calculator.security; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + */ +public class ServerPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Server User/Passwd Handler...."); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + System.out.println("User Id = " + pwcb.getIdentifer()); + System.out.println("Password = " + pwcb.getPassword()); + System.out.println("Usage = " + pwcb.getUsage()); + if ( pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN ) { + if ( pwcb.getIdentifer().equals("CalculatorUser") && + pwcb.getPassword().equals("CalculatorUserPasswd") ){ + return; + } else { + throw new UnsupportedCallbackException(pwcb, "Authentication Failed : UserId - Password mismatch"); + } + } else if ( pwcb.getUsage() == WSPasswordCallback.SIGNATURE ) { + if ( pwcb.getIdentifer().equals("CalculatorUser")) { + pwcb.setPassword("CalculatorUserPasswd"); + } else { + pwcb.setPassword("CalculatorAdmin"); + } + } + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/Calculator.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..4d511f887e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/Calculator.composite @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler new file mode 100644 index 0000000000..858e87a34f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler @@ -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. +# +# PolicyHandlerClasses to interpret specific PolicyModels against specific QoS infrastructures +# handler classname;qname=;model= +org.apache.tuscany.sca.policy.security.ws.Axis2ConfigParamPolicyHandler;intent=http://calculator#wsAuthentication,model=org.apache.tuscany.sca.policy.security.ws.Axis2ConfigParamPolicy +org.apache.tuscany.sca.policy.security.ws.WSSecurityPolicyHandler;intent=http://calculator#wsIntegrity,model=org.apache.neethi.Policy \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/calculatorKeys.jks b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/calculatorKeys.jks new file mode 100644 index 0000000000..b6b244244b Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/calculatorKeys.jks differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/definitions.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/definitions.xml new file mode 100644 index 0000000000..4611669bbd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/definitions.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + UsernameToken + calculator.security.ServerPWCBHandler + + + + + + + + + + UsernameToken + CalculatorUser + calculator.security.ClientPWCBHandler" + + PasswordText + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CalculatorAdmin + CalculatorAdmin + calculator.security.ServerPWCBHandler + + + + JKS + calculatorKeys.jks + CalculatorAdmin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CalculatorAdmin + CalculatorAdmin + calculator.security.ClientPWCBHandler + + + + JKS + calculatorKeys.jks + CalculatorAdmin + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/security.properties b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/security.properties new file mode 100644 index 0000000000..a7a6f3aa9c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/resources/security.properties @@ -0,0 +1,4 @@ +org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin +org.apache.ws.security.crypto.merlin.keystore.type=jks +org.apache.ws.security.crypto.merlin.keystore.password=CalculatorAdmin +org.apache.ws.security.crypto.merlin.file=calculatorKeys.jks \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-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-20080910/samples/calculator-ws-secure-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-20080910/samples/calculator-ws-secure-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..9b2a05d582 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,33 @@ + + + + + + + org.apache.tuscany.sca + sample-calculator-ws-webapp + 1.4-SNAPSHOT + war + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..d3a62d39f4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + + + Apache Tuscany Calculator Web Service Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + calc.jsp + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/webapp/calc.jsp b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-webapp/src/main/webapp/calc.jsp new file mode 100644 index 0000000000..4c4366747d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-secure-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 = (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-20080910/samples/calculator-ws-webapp/README b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/README new file mode 100644 index 0000000000..a6e6c897e4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/README @@ -0,0 +1,108 @@ +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-ws-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-ws-webapp + +The sample is configured to use a service on port 8080. If your servlet container +is using a port other than 8080 then you will need to edit the Calculator.composite +and change the uri attribute of the used by the CalculatorServiceComponent +to use the correct port. + +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. + +calculator-webapp/ + src/ + main/ + java/ + calculator/ + AddService.java - As calculator sample + AddServiceImpl.java + CalculatorClient.java - As calculator sample + CalculatorService.java - As calculator sample + CalculatorServiceImpl.java + DivideService.java - As calculator sample + DivideServiceImpl.java + MultiplyService.java - As calculator sample + MultiplyServiceImpl.java + SubtractService.java - As calculator sample + SubtractServiceImpl.java + 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 + + calculator.png - a pictorial representation of the sample .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + README - this file + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built using Ant as +follows + +cd calculator-ws-webapp +ant package + +This should result in a war file (sample-calculator-ws-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-ws-webapp + +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-ws-webapp +mvn + +Again this should result in a war file (sample-calculator-ws-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-20080910/samples/calculator-ws-webapp/calculator-web.png b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/calculator-web.png new file mode 100644 index 0000000000..f482b8d1c8 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/calculator-web.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/calculator-web.svg b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/calculator-web.svg new file mode 100644 index 0000000000..1b7015b156 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/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-20080910/samples/calculator-ws-webapp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/pom.xml new file mode 100644 index 0000000000..0d8a74c2bf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/pom.xml @@ -0,0 +1,102 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-calculator-ws-webapp + war + Apache Tuscany SCA Calculator Sample Web Service in a WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + generate + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..c3c789e745 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/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-20080910/samples/calculator-ws-webapp/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..a7049729f7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/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-20080910/samples/calculator-ws-webapp/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..4787b728f4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-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-20080910/samples/calculator-ws-webapp/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..ad87375529 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-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-20080910/samples/calculator-ws-webapp/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..bf3b0303ec --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-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-20080910/samples/calculator-ws-webapp/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..835e4fda6d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-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-20080910/samples/calculator-ws-webapp/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..8c33862f6d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-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-20080910/samples/calculator-ws-webapp/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-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-20080910/samples/calculator-ws-webapp/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..c7fbc73c00 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-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-20080910/samples/calculator-ws-webapp/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..30e4e6a56a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-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-20080910/samples/calculator-ws-webapp/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1a7f145ad8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-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-20080910/samples/calculator-ws-webapp/src/main/resources/Calculator.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..6415d5a896 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/resources/Calculator.composite @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-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-20080910/samples/calculator-ws-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-20080910/samples/calculator-ws-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..5da8c962a0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,34 @@ + + + + + + + org.apache.tuscany.sca + sample-calculator-ws-webapp + 1.4-SNAPSHOT + war + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..d3a62d39f4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + + + Apache Tuscany Calculator Web Service Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + calc.jsp + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/webapp/calc.jsp b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-webapp/src/main/webapp/calc.jsp new file mode 100644 index 0000000000..4c4366747d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator-ws-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 = (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-20080910/samples/calculator/README b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/README new file mode 100644 index 0000000000..ceb532faed --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/build.xml new file mode 100644 index 0000000000..c4b755ef94 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator/calculator.png b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/calculator.png new file mode 100644 index 0000000000..995a57b1fd Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/calculator.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator/calculator.svg b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/calculator.svg new file mode 100644 index 0000000000..0615925c50 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/calculator/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/pom.xml new file mode 100644 index 0000000000..4a2216c2e9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/pom.xml @@ -0,0 +1,71 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-calculator + Apache Tuscany SCA Calculator Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..7ca8fb04b5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Adding " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..3b2966e96d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; + +/** + * 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 { + + SCANodeFactory factory = SCANodeFactory.newInstance(); + SCANode node = factory.createSCANodeFromClassLoader("Calculator.composite", CalculatorClient.class.getClassLoader()); + node.start(); + + CalculatorService calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + + // Calculate + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + + node.stop(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..1323edf55a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2); + return n1 / n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..91b803bc9e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2); + return n1 * n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..58cc4a3547 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2); + return n1 - n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/resources/Calculator.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..90872041b0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/main/resources/Calculator.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/test/java/calculator/CalculatorTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..1b7476534a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator/src/test/java/calculator/CalculatorTestCase.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 calculator; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; + +/** + * This shows how to test the Calculator service component. + */ +public class CalculatorTestCase extends TestCase { + + private CalculatorService calculatorService; + private SCANode node; + + @Override + protected void setUp() throws Exception { + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANodeFromClassLoader("Calculator.composite", getClass().getClassLoader()); + node.start(); + + calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + } + + @Override + protected void tearDown() throws Exception { + node.stop(); + } + + 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-20080910/samples/calculator2/README b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/README new file mode 100644 index 0000000000..ceb532faed --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/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-20080910/samples/calculator2/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/build.xml new file mode 100644 index 0000000000..c4b755ef94 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/calculator.png b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/calculator.png new file mode 100644 index 0000000000..995a57b1fd Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/calculator.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/calculator.svg b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/calculator.svg new file mode 100644 index 0000000000..0615925c50 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/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-20080910/samples/calculator2/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/pom.xml new file mode 100644 index 0000000000..fd6aaefdc7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-calculator2 + Apache Tuscany SCA Calculator Sample + + + + + org.apache.tuscany.sca + tuscany-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-scdl4j + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-runtime2 + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..188451ebac --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/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-20080910/samples/calculator2/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..7ca8fb04b5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Adding " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..9d180bf52e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/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-20080910/samples/calculator2/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..031fa8b912 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/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-20080910/samples/calculator2/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..3d861f2018 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/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-20080910/samples/calculator2/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/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-20080910/samples/calculator2/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..1323edf55a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2); + return n1 / n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/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-20080910/samples/calculator2/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..91b803bc9e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2); + return n1 * n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..bf0d1882b6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/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-20080910/samples/calculator2/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..58cc4a3547 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2); + return n1 - n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/resources/Calculator.composite b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..90872041b0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/main/resources/Calculator.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/test/java/calculator/CalculatorTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..775ad15537 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/calculator2/src/test/java/calculator/CalculatorTestCase.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 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-20080910/samples/callback-ws-client/README b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/README new file mode 100644 index 0000000000..66121362c9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/README @@ -0,0 +1,311 @@ +Callback Web Services Client Sample +=================================== +This sample demonstrates an SCA client that sends service requests to a +remote server and receives asynchronous callbacks from the server, using +Web service bindings for the service and the 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, you need to start the +server first, so open a command prompt and navigate to the +callback-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-callback-ws-service.jar myserver.CallbackServer + +and on *nix do: + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-callback-ws-service.jar myserver.CallbackServer + +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-callback-ws-client.jar myapp.MyClientImpl + +and on *nix do: + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-callback-ws-client.jar myapp.MyClientImpl + + +Sample Overview +--------------- +The sample has a single component that has a reference with a service +interface and a callback interface, with Web service bindings for both +these interfaces. The service interface binding URI identifies the +service exposed by the callback-ws-service sample. + +callback-ws-client/ + src/ + main/ + java/ + myapp/ + MyClient.java - interface description for + MyClientComponent + MyClientImpl.java - component implementation + myserver/ + MyService.java - interface description for + MyServiceComponent + MyServiceCallback.java - interface description for callback + resources/ + myapp.composite - the SCA assembly for this sample + test/ + java/ + myapp/ + CallbackClientTestCase.java - JUnit test case + callback-ws-client.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, run the callback-ws-service sample to start up the +service that the client will talk to. Take a look at the README in +that sample and you will see you need the following commands: + +cd callback-ws-service +ant run + +You can then compile and run this sample using the following commands: + +cd callback-ws-client +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] 15-Jan-2008 10:21:38 org.apache.tuscany.sca.node.impl.SCADomainProxy +Impl init + [java] INFO: Domain will be started stand-alone as domain URL is not provid +ed + [java] 15-Jan-2008 10:21:39 org.apache.tuscany.sca.domain.impl.SCADomainImp +l registerNode + [java] INFO: Registered node: http://L3AW203:1336 at endpoint http://L3AW20 +3:1336 + [java] 15-Jan-2008 10:21:39 org.apache.tuscany.sca.node.impl.SCADomainProxy +Impl createRuntime + [java] INFO: Domain management configured from file:/C:/simon/tuscany/relea +se/sca-r1.1-rc2/tuscany-sca-1.1-incubating-SNAPSHOT/lib/tuscany-sca-all-1.1-incu +bating-SNAPSHOT.jar + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1336/SCADomainEventServi +ceProxyComponent + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1336/SCADomainAPIService +ProxyComponent + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1336/SCANodeManagerCompo +nent/SCANodeManagerService + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1336/SCANodeManagerCompo +nent/ComponentManagerService/* + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1336/SCANodeManagerCompo +nent/ComponentManagerService + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1336/SCADomain/scaDomain +.js + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.node.impl.SCANodeImpl ac +tivateComposite + [java] INFO: Building composite: {http://myapp}myapp + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.node.impl.SCANodeImpl st +artComposite + [java] INFO: Starting composite: {http://myapp}myapp + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1336/MyClientComponent/m +yService + [java] aClientMethod on thread Thread[main,5,main] + [java] aClientMethod return from someMethod on thread Thread[main,5,main] + [java] receiveResult on thread Thread[pool-1-thread-2,5,main] + [java] Result: -> someMethod -> receiveResult + [java] Closing the domain + [java] 15-Jan-2008 10:21:54 org.apache.tuscany.sca.node.impl.SCANodeImpl st +opComposite + [java] INFO: Stopping composite: {http://myapp}myapp + +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 +callback-ws-service sample first as Maven does this for you. With Maven, +both client and server code run in the same JVM, which rather defeats the +purpose of this sample (to show a standalone SCA client), but it's good +enough for a unit test. + +cd callback-ws-client +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running myapp.CallbackClientTestCase +15-Jan-2008 10:17:46 org.apache.tuscany.sca.node.impl.SCADomainProxyImpl init +INFO: Domain will be started stand-alone as domain URL is not provided +15-Jan-2008 10:17:46 org.apache.tuscany.sca.domain.impl.SCADomainImpl registerNo +de +INFO: Registered node: http://L3AW203:1322 at endpoint http://L3AW203:1322 +15-Jan-2008 10:17:46 org.apache.tuscany.sca.node.impl.SCADomainProxyImpl createR +untime +INFO: Domain management configured from file:/C:/Documents%20and%20Settings/slaw +s/.m2/repository/org/apache/tuscany/sca/tuscany-node-impl/1.1-incubating-SNAPSHO +T/tuscany-node-impl-1.1-incubating-SNAPSHOT.jar +15-Jan-2008 10:17:52 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +15-Jan-2008 10:17:53 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +15-Jan-2008 10:17:53 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +15-Jan-2008 10:17:53 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +1.dtd +15-Jan-2008 10:17:53 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +2.dtd +15-Jan-2008 10:17:53 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +15-Jan-2008 10:17:53 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +15-Jan-2008 10:17:53 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-1322 +15-Jan-2008 10:17:53 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-1322 +15-Jan-2008 10:17:53 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1322/SCADomainEventServiceProxyCompo +nent +15-Jan-2008 10:17:53 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1322/SCADomainAPIServiceProxyCompone +nt +15-Jan-2008 10:17:53 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1322/SCANodeManagerComponent/SCANode +ManagerService +15-Jan-2008 10:17:53 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1322/SCANodeManagerComponent/Compone +ntManagerService/* +15-Jan-2008 10:17:53 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1322/SCANodeManagerComponent/Compone +ntManagerService +15-Jan-2008 10:17:53 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1322/SCADomain/scaDomain.js +15-Jan-2008 10:17:53 org.apache.tuscany.sca.node.impl.SCANodeImpl activateCompos +ite +INFO: Building composite: {http://callbackws}callbackws +15-Jan-2008 10:17:54 org.apache.tuscany.sca.node.impl.SCANodeImpl startComposite + +INFO: Starting composite: {http://callbackws}callbackws +15-Jan-2008 10:17:54 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +15-Jan-2008 10:17:54 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +15-Jan-2008 10:17:54 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8086 +15-Jan-2008 10:17:54 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8086 +15-Jan-2008 10:17:54 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8086/MyServiceComponent +15-Jan-2008 10:17:54 org.apache.tuscany.sca.node.impl.SCADomainProxyImpl init +INFO: Domain will be started stand-alone as domain URL is not provided +15-Jan-2008 10:17:54 org.apache.tuscany.sca.domain.impl.SCADomainImpl registerNo +de +INFO: Registered node: http://L3AW203:1323 at endpoint http://L3AW203:1323 +15-Jan-2008 10:17:54 org.apache.tuscany.sca.node.impl.SCADomainProxyImpl createR +untime +INFO: Domain management configured from file:/C:/Documents%20and%20Settings/slaw +s/.m2/repository/org/apache/tuscany/sca/tuscany-node-impl/1.1-incubating-SNAPSHO +T/tuscany-node-impl-1.1-incubating-SNAPSHOT.jar +15-Jan-2008 10:17:56 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +15-Jan-2008 10:17:56 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +15-Jan-2008 10:17:56 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-1323 +15-Jan-2008 10:17:56 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-1323 +15-Jan-2008 10:17:56 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1323/SCADomainEventServiceProxyCompo +nent +15-Jan-2008 10:17:56 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1323/SCADomainAPIServiceProxyCompone +nt +15-Jan-2008 10:17:56 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1323/SCANodeManagerComponent/SCANode +ManagerService +15-Jan-2008 10:17:56 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1323/SCANodeManagerComponent/Compone +ntManagerService/* +15-Jan-2008 10:17:56 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1323/SCANodeManagerComponent/Compone +ntManagerService +15-Jan-2008 10:17:56 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1323/SCADomain/scaDomain.js +15-Jan-2008 10:17:56 org.apache.tuscany.sca.node.impl.SCANodeImpl activateCompos +ite +INFO: Building composite: {http://myapp}myapp +15-Jan-2008 10:17:57 org.apache.tuscany.sca.node.impl.SCANodeImpl startComposite + +INFO: Starting composite: {http://myapp}myapp +15-Jan-2008 10:17:57 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1323/MyClientComponent/myService +aClientMethod on thread Thread[main,5,main] +aClientMethod return from someMethod 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] +Sleeping ... +receiveResult on thread Thread[pool-2-thread-1,5,main] +Result: -> someMethod -> receiveResult +Closing the domain +15-Jan-2008 10:18:02 org.apache.tuscany.sca.node.impl.SCANodeImpl stopComposite +INFO: Stopping composite: {http://myapp}myapp +15-Jan-2008 10:18:03 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-1323 +15-Jan-2008 10:18:03 org.apache.tuscany.sca.node.impl.SCANodeImpl stopComposite +INFO: Stopping composite: {http://callbackws}callbackws +15-Jan-2008 10:18:03 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8086 +15-Jan-2008 10:18:03 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-1322 +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 17.343 sec + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/build.xml new file mode 100644 index 0000000000..8698c6018d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/callback-ws-client.png b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/callback-ws-client.png new file mode 100644 index 0000000000..802ef604a7 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/callback-ws-client.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/callback-ws-client.svg b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/callback-ws-client.svg new file mode 100644 index 0000000000..f49aeadbbf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/callback-ws-client.svg @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + myapp + + MyClientComponent + + http://localhost:8086/MyServiceComponent + + myservice callback + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/pom.xml new file mode 100644 index 0000000000..c45691febb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/pom.xml @@ -0,0 +1,86 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-callback-ws-client + Apache Tuscany SCA Callback Web Service Remote Client Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + org.apache.tuscany.sca + sample-callback-ws-service + 1.4-SNAPSHOT + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myapp/MyClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myapp/MyClient.java new file mode 100644 index 0000000000..e515b55788 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myapp/MyClient.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 myapp; + +import org.osoa.sca.annotations.OneWay; + +/** + * The client interface + */ +public interface MyClient { + + void aClientMethod(); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myapp/MyClientImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myapp/MyClientImpl.java new file mode 100644 index 0000000000..ece769236c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myapp/MyClientImpl.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 myapp; + +import myserver.MyService; +import myserver.MyServiceCallback; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * Remote Web service client with callback interface + */ +@Service(MyClient.class) +@Scope("COMPOSITE") +public class MyClientImpl implements MyClient, MyServiceCallback { + @Reference + protected MyService myService; + + public void aClientMethod() { + System.out.println("aClientMethod on thread " + Thread.currentThread()); + myService.someMethod(" -> someMethod "); // calls the server + System.out.println("aClientMethod return from someMethod on thread " + Thread.currentThread()); + } + + public void receiveResult(String result) { + System.out.println("receiveResult on thread " + Thread.currentThread()); + System.out.println("Result: " + result); // callback from the server + } + + public static void main(String[] args) throws Exception { + SCANode node = SCANodeFactory.newInstance().createSCANodeFromClassLoader("myapp.composite", MyClientImpl.class.getClassLoader()); + node.start(); + run(node); + System.out.println("Closing the domain"); + node.stop(); + } + + public static void run(SCANode node) throws InterruptedException { + MyClient myClient = ((SCAClient)node).getService(MyClient.class, "MyClientComponent"); + myClient.aClientMethod(); + Thread.sleep(5000); // don't exit before callback arrives + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myserver/MyService.java b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myserver/MyService.java new file mode 100644 index 0000000000..1850eae1bc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myserver/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 myserver; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +/** + * The remote service that will be invoked by the client + */ +@Remotable +@Callback(MyServiceCallback.class) +public interface MyService { + + @OneWay + void someMethod(String arg); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myserver/MyServiceCallback.java b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myserver/MyServiceCallback.java new file mode 100644 index 0000000000..bf5f87a4f9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/java/myserver/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 myserver; + +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-20080910/samples/callback-ws-client/src/main/resources/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..314747d548 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/resources/myapp.composite b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/resources/myapp.composite new file mode 100644 index 0000000000..5b776d6df8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/main/resources/myapp.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/test/java/myapp/CallbackClientTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/test/java/myapp/CallbackClientTestCase.java new file mode 100644 index 0000000000..fb2f6952c4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-client/src/test/java/myapp/CallbackClientTestCase.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 myapp; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests that the callback server is available + */ +public class CallbackClientTestCase { + + private SCANode node; + + @Before + public void startServer() throws Exception { + try { + node = SCANodeFactory.newInstance().createSCANodeFromClassLoader(null, getClass().getClassLoader()); + node.start(); + } catch (Exception ex) { + System.out.println(ex.toString()); + } + } + + @Test + public void testClient() throws Exception { + MyClientImpl.run(node); + } + + @After + public void stopServer() throws Exception { + node.stop(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/README b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/README new file mode 100644 index 0000000000..2c65f745a6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/README @@ -0,0 +1,227 @@ +Callback Web Services Service Sample +=================================== +This sample demonstrates an SCA service with callback to a remote client +using Web service bindings for the service and the 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-callback-ws-service.jar myserver.CallbackServer + +and on *nix do: + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-callback-ws-service.jar myserver.CallbackServer + +Now the server is started you can use the callback-ws-client sample to +exercise it. + +Sample Overview +--------------- +The sample has a single component that provides a service that is +invoked from a remote client over Web services and makes an SCA callback +over Web services to the same remote client. + +callback-ws-service/ + src/ + main/ + java/ + myserver/ + MyService.java - interface description for + MyServiceComponent + MyServiceCallback.java - interface description for callback + NyServiceImpl.java - component implementation + CallbackServer.java - starts the SCA runtime and + deploys the callbackws.composite + and then waits for the service + to be called via Web services + resources/ + callbackws.composite - the SCA assembly for this sample + test/ + java/ + myserver/ + CallbackServerTestCase.java - JUnit test case + callback-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 with +the following commands: + +cd callback-ws-service +ant compile +ant run + +You should see the following output from the run target: + +run: + [java] 15-Jan-2008 10:21:14 org.apache.tuscany.sca.node.impl.SCADomainProxy +Impl init + [java] INFO: Domain will be started stand-alone as domain URL is not provid +ed + [java] 15-Jan-2008 10:21:14 org.apache.tuscany.sca.domain.impl.SCADomainImp +l registerNode + [java] INFO: Registered node: http://L3AW203:1331 at endpoint http://L3AW20 +3:1331 + [java] 15-Jan-2008 10:21:14 org.apache.tuscany.sca.node.impl.SCADomainProxy +Impl createRuntime + [java] INFO: Domain management configured from file:/C:/simon/tuscany/relea +se/sca-r1.1-rc2/tuscany-sca-1.1-incubating-SNAPSHOT/lib/tuscany-sca-all-1.1-incu +bating-SNAPSHOT.jar + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1331/SCADomainEventServi +ceProxyComponent + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1331/SCADomainAPIService +ProxyComponent + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1331/SCANodeManagerCompo +nent/SCANodeManagerService + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1331/SCANodeManagerCompo +nent/ComponentManagerService/* + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1331/SCANodeManagerCompo +nent/ComponentManagerService + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1331/SCADomain/scaDomain +.js + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.node.impl.SCANodeImpl ac +tivateComposite + [java] INFO: Building composite: {http://callbackws}callbackws + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] 15-Jan-2008 10:21:24 org.apache.tuscany.sca.node.impl.SCANodeImpl st +artComposite + [java] INFO: Starting composite: {http://callbackws}callbackws + [java] 15-Jan-2008 10:21:26 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] Callback 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, press enter. + +To exercise the service, run the callback-ws-client sample. Take a look at +the README in that sample and you will see you need the following commands: + +cd callback-ws-client +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 +callback-ws-client sample as the Maven build uses a simple ping test to +make sure that the service is available. + +cd callback-ws-service +mvn + +You should see the following output from the test phase: + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running myserver.CallbackServerTestCase +15-Jan-2008 10:29:36 org.apache.tuscany.sca.node.impl.SCADomainProxyImpl init +INFO: Domain will be started stand-alone as domain URL is not provided +15-Jan-2008 10:29:36 org.apache.tuscany.sca.domain.impl.SCADomainImpl registerNo +de +INFO: Registered node: http://L3AW203:1365 at endpoint http://L3AW203:1365 +15-Jan-2008 10:29:36 org.apache.tuscany.sca.node.impl.SCADomainProxyImpl createR +untime +INFO: Domain management configured from file:/C:/Documents%20and%20Settings/slaw +s/.m2/repository/org/apache/tuscany/sca/tuscany-node-impl/1.1-incubating-SNAPSHO +T/tuscany-node-impl-1.1-incubating-SNAPSHOT.jar +15-Jan-2008 10:29:42 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +15-Jan-2008 10:29:42 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +15-Jan-2008 10:29:42 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +15-Jan-2008 10:29:42 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +1.dtd +15-Jan-2008 10:29:42 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +2.dtd +15-Jan-2008 10:29:42 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +15-Jan-2008 10:29:42 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +15-Jan-2008 10:29:42 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-1365 +15-Jan-2008 10:29:42 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-1365 +15-Jan-2008 10:29:42 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1365/SCADomainEventServiceProxyCompo +nent +15-Jan-2008 10:29:42 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1365/SCADomainAPIServiceProxyCompone +nt +15-Jan-2008 10:29:43 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1365/SCANodeManagerComponent/SCANode +ManagerService +15-Jan-2008 10:29:43 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1365/SCANodeManagerComponent/Compone +ntManagerService/* +15-Jan-2008 10:29:43 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1365/SCANodeManagerComponent/Compone +ntManagerService +15-Jan-2008 10:29:43 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1365/SCADomain/scaDomain.js +15-Jan-2008 10:29:43 org.apache.tuscany.sca.node.impl.SCANodeImpl activateCompos +ite +INFO: Building composite: {http://callbackws}callbackws +15-Jan-2008 10:29:43 org.apache.tuscany.sca.node.impl.SCANodeImpl startComposite + +INFO: Starting composite: {http://callbackws}callbackws +15-Jan-2008 10:29:43 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +15-Jan-2008 10:29:43 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +15-Jan-2008 10:29:43 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8086 +15-Jan-2008 10:29:43 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8086 +15-Jan-2008 10:29:43 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8086/MyServiceComponent +15-Jan-2008 10:29:43 org.apache.tuscany.sca.node.impl.SCANodeImpl stopComposite +INFO: Stopping composite: {http://callbackws}callbackws +15-Jan-2008 10:29:43 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8086 +15-Jan-2008 10:29:43 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-1365 +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.422 sec + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/build.xml new file mode 100644 index 0000000000..c91dd88a8c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/callback-ws-service.png b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/callback-ws-service.png new file mode 100644 index 0000000000..772ac38431 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/callback-ws-service.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/callback-ws-service.svg b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/callback-ws-service.svg new file mode 100644 index 0000000000..ff0a1d307b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/callback-ws-service.svg @@ -0,0 +1,200 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + callbackws + + MyServiceComponent + http://localhost:8086/MyServiceComponent + + myservice callback + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/pom.xml new file mode 100644 index 0000000000..789f981d49 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-callback-ws-service + Apache Tuscany SCA Callback Web Service Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/java/myserver/CallbackServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/java/myserver/CallbackServer.java new file mode 100644 index 0000000000..75ef05bc48 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/java/myserver/CallbackServer.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 myserver; + +import java.io.IOException; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; + +/** + * This server program shows how to create and start an SCA runtime that + * activates the MyService Web service endpoint. + */ +public class CallbackServer { + + public static void main(String[] args) throws Exception { + + SCANode node = SCANodeFactory.newInstance().createSCANodeFromClassLoader("callbackws.composite", null); + node.start(); + + try { + System.out.println("Callback server started (press enter to shutdown)"); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + node.stop(); + System.out.println("Callback server stopped"); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/java/myserver/MyService.java b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/java/myserver/MyService.java new file mode 100644 index 0000000000..1850eae1bc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/java/myserver/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 myserver; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +/** + * The remote service that will be invoked by the client + */ +@Remotable +@Callback(MyServiceCallback.class) +public interface MyService { + + @OneWay + void someMethod(String arg); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/java/myserver/MyServiceCallback.java b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/java/myserver/MyServiceCallback.java new file mode 100644 index 0000000000..bf5f87a4f9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/java/myserver/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 myserver; + +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-20080910/samples/callback-ws-service/src/main/java/myserver/MyServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/java/myserver/MyServiceImpl.java new file mode 100644 index 0000000000..25469def5c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/java/myserver/MyServiceImpl.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 myserver; + +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 { + System.out.println("Sleeping ..."); + Thread.sleep(2000); + myServiceCallback.receiveResult(arg + " -> receiveResult "); + } catch(Exception e) { + System.out.println("RuntimeException invoking receiveResult: " + e.toString()); + e.printStackTrace(); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/resources/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..35f7f60c2e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/resources/callbackws.composite b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/resources/callbackws.composite new file mode 100644 index 0000000000..a09e638896 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/main/resources/callbackws.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/test/java/myserver/CallbackServerTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/test/java/myserver/CallbackServerTestCase.java new file mode 100644 index 0000000000..e87667cc3e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callback-ws-service/src/test/java/myserver/CallbackServerTestCase.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 myserver; + +import java.io.IOException; +import java.net.Socket; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests that the callback server is available + */ +public class CallbackServerTestCase { + + private SCANode node; + + @Before + public void startServer() throws Exception { + node = SCANodeFactory.newInstance().createSCANodeFromClassLoader("callbackws.composite", null); + node.start(); + } + + @Test + public void testPing() throws IOException { + new Socket("127.0.0.1", 8086); + } + + @After + public void stopServer() throws Exception { + node.stop(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/README b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/README new file mode 100644 index 0000000000..b5e130e2fc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/README @@ -0,0 +1,73 @@ +Callback JMS Sample +=================== +This sample demonstrates SCA callbacks over the JMS binding. It implements the example +described in the INFOQ article: + + "Can I call you back about that?" Building Asynchronous Services using Service Component Architecture + See: http://www.infoq.com/articles/async-sca + +It implements a service for placing an order for some widgets, where the service is asynchronous +and the client is informed of progress via a callback interface. + +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-callbacks-jms.jar callbacks.CallbacksTestCase + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-callbacks-jms.jar callbacks.CallbacksTestCase + +Sample Overview +--------------- + +The only changes over the sample code described in the INFOQ article are to add the @Remotable annotation +to the service and callback interfaces, add the @Oneway annotation to the placeOrder and placeOrderResponse +methods, and the composite XML is changed to use instead of . + + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant as +follows + +cd callbacks-jms +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] client placing order: callbacks.OrderRequest@c72243 + [java] service received order: callbacks.OrderRequest@1f94884 + [java] client callback received order response: callbacks.OrderResponse@14ab51b + +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 callbacks-jms +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running callbacks.CallbacksTestCase +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-20080910/samples/callbacks-jms/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/build.xml new file mode 100644 index 0000000000..665feeca71 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/pom.xml new file mode 100644 index 0000000000..5d7b1453b4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/pom.xml @@ -0,0 +1,92 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-callbacks-jms + Apache Tuscany SCA Callbacks with JMS Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + org.apache.activemq + activemq-core + 5.1.0 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderCallback.java b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderCallback.java new file mode 100644 index 0000000000..775663cdff --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderCallback.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 callbacks; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface OrderCallback { + + @OneWay + public void placeOrderResponse(OrderResponse orderResponse); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderRequest.java b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderRequest.java new file mode 100644 index 0000000000..69f5751379 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderRequest.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 callbacks; + +public class OrderRequest { + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderResponse.java b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderResponse.java new file mode 100644 index 0000000000..882bcf8479 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderResponse.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 callbacks; + +public class OrderResponse { + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderService.java b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderService.java new file mode 100644 index 0000000000..9f6d90577c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderService.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 callbacks; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +@Remotable +@Callback(OrderCallback.class) +public interface OrderService { + + @OneWay + public void placeOrder(OrderRequest orderRequest); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderServiceClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderServiceClient.java new file mode 100644 index 0000000000..3393ae5dca --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderServiceClient.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 callbacks; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +@Service(OrderServiceClient.class) +public class OrderServiceClient implements OrderCallback { + + // A field to hold the reference to the order service + + private OrderService orderService; + public static OrderResponse oResponse; + + public void doSomeOrdering() { + + OrderRequest oRequest = new OrderRequest(); + + // … fill in the details of the order … + + System.out.println("client placing order: " + oRequest); + + orderService.placeOrder(oRequest); + + // …the client code can continue to do processing + } + + public void placeOrderResponse(OrderResponse oResponse) { + + // …handle the response as needed + + System.out.println("client callback received order response: " + oResponse); + OrderServiceClient.oResponse = oResponse; + } + + // A setter method for the order service reference + @Reference + public void setOrderService(OrderService theService) { + orderService = theService; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderServiceImpl.java new file mode 100644 index 0000000000..dd963bc1b0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/java/callbacks/OrderServiceImpl.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 callbacks; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Service; + +@Service(OrderService.class) +public class OrderServiceImpl implements OrderService { + + // A field for the callback reference object + private OrderCallback callbackReference; + + // The place order operation itself + public void placeOrder(OrderRequest oRequest) { + + // …do the work to process the order… + // …which may take some time… + + System.out.println("service received order: " + oRequest); + + // when ready to respond… + + OrderResponse theResponse = new OrderResponse(); + + callbackReference.placeOrderResponse(theResponse); + } + + // A setter method for the callback reference + @Callback + public void setCallbackReference(OrderCallback theCallback) { + callbackReference = theCallback; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/resources/callbacks.composite b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/resources/callbacks.composite new file mode 100644 index 0000000000..94dd29c45d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/resources/callbacks.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/resources/jndi.properties b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/resources/jndi.properties new file mode 100644 index 0000000000..698aeb1711 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/main/resources/jndi.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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false&broker.useJmx=false + +# use the following property to specify the JNDI name the connection factory should appear as. +connectionFactoryNames = ConnectionFactory + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] +queue.OrderService = OrderServiceQueue diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/test/java/callbacks/CallbacksTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/test/java/callbacks/CallbacksTestCase.java new file mode 100644 index 0000000000..967fc42c64 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/callbacks-jms/src/test/java/callbacks/CallbacksTestCase.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 callbacks; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This shows how to test the Calculator service component. + */ +public class CallbacksTestCase extends TestCase { + + private OrderServiceClient orderServiceClient; + private SCADomain scaDomain; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("callbacks.composite"); + orderServiceClient = scaDomain.getService(OrderServiceClient.class, "ClientComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testOderClient() throws Exception { + + orderServiceClient.doSomeOrdering(); + + // wait to give the service time to respond + Thread.sleep(500); + } + + public static void main(String[] args) { + try { + + CallbacksTestCase runner = new CallbacksTestCase(); + runner.setUp(); + runner.testOderClient(); + runner.tearDown(); + + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/README b/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/README new file mode 100644 index 0000000000..dddd7e3f94 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/chat-webapp/chat-webapp.png b/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/chat-webapp.png new file mode 100644 index 0000000000..fdf540d243 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/chat-webapp.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/chat-webapp.svg b/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/chat-webapp.svg new file mode 100644 index 0000000000..b37c1dc590 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/chat-webapp.svg @@ -0,0 +1,187 @@ + + + + + + + + + + image/svg+xml + + + + + + + + store + + + DWR + + + DWR + + Catalog + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/pom.xml new file mode 100644 index 0000000000..50be91f202 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/pom.xml @@ -0,0 +1,97 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-chat-webapp + war + Apache Tuscany SCA Chat Sample WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-dwr + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + generate + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/java/sample/ChatService.java b/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/java/sample/ChatService.java new file mode 100644 index 0000000000..ca90b8f579 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/java/sample/ChatService.java @@ -0,0 +1,26 @@ +/** + * + * 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; + +@Remotable +public interface ChatService { + + public void chat(String msg); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/java/sample/ChatServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/chat-webapp/src/main/resources/chat.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/chat-webapp/src/main/resources/chat.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..97d91fec56 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,37 @@ + + + + + + Apache Tuscany AJAX/DWR Chat Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + chat.html + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/webapp/chat.html b/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/webapp/chat.html new file mode 100644 index 0000000000..7a449a906a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/chat-webapp/src/main/webapp/chat.html @@ -0,0 +1,70 @@ + + + + Apache Tuscany Ajax/DWR Chat Sample + + + + + + + + +

Apache 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-20080910/samples/chat2-webapp/README b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/README new file mode 100644 index 0000000000..0186006211 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-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-20080910/samples/chat2-webapp/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/build.xml new file mode 100644 index 0000000000..2d3fc0c5f3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/build.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/pom.xml new file mode 100644 index 0000000000..c9def0ae48 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/pom.xml @@ -0,0 +1,104 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-chat2-webapp + war + Apache Tuscany SCA Chat Sample WebApp using callbacks + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-dwr + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-web + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + generate + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/java/sample/ChatCallback.java b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/java/sample/ChatCallback.java new file mode 100644 index 0000000000..7d668052b2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/java/sample/ChatCallback.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package sample; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface ChatCallback { + void newMsg(String msg); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/java/sample/ChatService.java b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/java/sample/ChatService.java new file mode 100644 index 0000000000..cc9d00ca4a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/java/sample/ChatService.java @@ -0,0 +1,32 @@ +/** + * + * 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 javax.jws.Oneway; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Scope; + +@Remotable +@Scope("COMPOSITE") +@Callback(ChatCallback.class) +public interface ChatService { + + @Oneway + public void addMsg(String msg); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/java/sample/ChatServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/java/sample/ChatServiceImpl.java new file mode 100644 index 0000000000..d714ff82ed --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-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.Callback; + +public class ChatServiceImpl implements ChatService { + + ChatCallback chatCallback; + + @Callback + public void setCallback(ChatCallback chatCallback) { + this.chatCallback = chatCallback; + } + + public void addMsg(String msg) { + chatCallback.newMsg(msg); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/resources/chat.composite b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/resources/chat.composite new file mode 100644 index 0000000000..93a10d0fdf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/resources/chat.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-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-20080910/samples/chat2-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-20080910/samples/chat2-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..6919372e87 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,37 @@ + + + + + + Apache Tuscany AJAX/DWR Chat Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + chat.jsp + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/webapp/chat.html b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/webapp/chat.html new file mode 100644 index 0000000000..a063e27f8e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/chat2-webapp/src/main/webapp/chat.html @@ -0,0 +1,73 @@ + + + + Apache Tuscany Ajax/DWR Chat Sample + + + + + + +

Apache 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-20080910/samples/customer-dojo/README b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/README new file mode 100644 index 0000000000..9c1729123f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/README @@ -0,0 +1,104 @@ +Customer Dojo RPC Sample +=========================== + +Note. This sample is currently not working correctly on WebSphere - see TUSCANY-1990 + +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-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-helloworld-dojo-webapp + +The port and hostname will of course vary depending on your local installation. + +See also the similar helloworld-jsonrpc-webapp 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-webapp/ + 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-webapp.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-webapp +ant package + +This should result in a war file (sample-helloworld-dojo-webapp.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-webapp + +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-webapp +mvn + +Again this should result in a war file (sample-helloworld-dojo-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-20080910/samples/customer-dojo/build-dojo.xml b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/build-dojo.xml new file mode 100644 index 0000000000..8c6bd99484 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/build-dojo.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/build.xml new file mode 100644 index 0000000000..95813af65a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/build.xml @@ -0,0 +1,70 @@ + + +]> + + + + &buildDependency; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/customer-dojo-jsonrpc.png b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/customer-dojo-jsonrpc.png new file mode 100644 index 0000000000..57f90aed01 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/customer-dojo-jsonrpc.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/customer-dojo-jsonrpc.svg b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/customer-dojo-jsonrpc.svg new file mode 100644 index 0000000000..d5c3bc5d3e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/customer-dojo-jsonrpc.svg @@ -0,0 +1,177 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldjsonrpc + + HelloWorldJSONServiceComponent + HelloWorldService + WebApp + DOJO + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/customer.sql b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/customer.sql new file mode 100644 index 0000000000..a3caf8e050 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/customer.sql @@ -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. +-- + +DROP TABLE CUSTOMER; + +CREATE TABLE CUSTOMER ( + ID INT PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY, + NAME VARCHAR(30), + PHONE VARCHAR(10), + ADDRESS VARCHAR(25), + CITY VARCHAR(15), + STATE VARCHAR(2), + ZIP VARCHAR(5)); + +INSERT INTO CUSTOMER (NAME, PHONE, ADDRESS, CITY, STATE, ZIP ) VALUES('Joe Smith', '4081234567', '1440 N 1st ST', 'SAN JOSE', 'CA', '95134'); +INSERT INTO CUSTOMER (NAME, PHONE, ADDRESS, CITY, STATE, ZIP ) VALUES('Erik Johnson', '4081230987', '1440 N 1st ST', 'SAN JOSE', 'CA', '95134'); +INSERT INTO CUSTOMER (NAME, PHONE, ADDRESS, CITY, STATE, ZIP ) VALUES('Mark Pensacola', '4085679988', '1440 N 1st ST', 'SAN JOSE', 'CA', '95134'); \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/pom.xml new file mode 100644 index 0000000000..305ca8ada0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/pom.xml @@ -0,0 +1,245 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-customer-dojo + Apache Tuscany SCA Customer DOJO Sample WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-data-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-resource-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.4-SNAPSHOT + + + + org.apache.geronimo.specs + geronimo-jpa_3.0_spec + 1.1 + + + + org.apache.openjpa + openjpa + 1.0.0 + + + javax.xml.bind + jaxb-api + + + + + + org.apache.derby + derby + 10.1.2.1 + + + + 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 + + + + + + + + + + + + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + true + + + generate + + + + + + org.codehaus.mojo + sql-maven-plugin + + 1.1-SNAPSHOT + + + + org.apache.derby + derby + 10.3.1.4 + + + + + + create-db + generate-resources + + execute + + + org.apache.derby.jdbc.EmbeddedDriver + jdbc:derby:${pom.basedir}/target/classes/customer;create=true + true + continue + skip + ; + + ${pom.basedir}/customer.sql + + + + + + + shutdown-database-sothat-test-can-run + process-test-resources + + execute + + + org.apache.derby.jdbc.EmbeddedDriver + jdbc:derby:${pom.basedir}/target/classes/customer;shutdown=true + true + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/Customer.java b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/Customer.java new file mode 100644 index 0000000000..6d207ea2ef --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/Customer.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package customer; + +import javax.persistence.Basic; +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class Customer { + + @Id protected int id; + @Basic protected String name; + @Basic protected String phone; + @Basic protected String address; + @Basic protected String city; + @Basic protected String state; + @Basic protected String zip; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getZip() { + return zip; + } + + public void setZip(String zip) { + this.zip = zip; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerCollection.java b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerCollection.java new file mode 100644 index 0000000000..5ad39aad5c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerCollection.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 customer; + +import org.apache.tuscany.sca.data.collection.Collection; + + +public interface CustomerCollection extends Collection { + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerCollectionImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerCollectionImpl.java new file mode 100644 index 0000000000..c0a2f25f15 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerCollectionImpl.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 customer; + +import java.util.Iterator; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.EntityTransaction; +import javax.persistence.Persistence; +import javax.persistence.Query; + +import org.apache.tuscany.sca.data.collection.Entry; +import org.apache.tuscany.sca.data.collection.NotFoundException; + + +public class CustomerCollectionImpl implements CustomerCollection { + EntityManagerFactory emf = null; + EntityManager em = null; + + public CustomerCollectionImpl() { + System.out.println(">>>"); + try { + emf = Persistence.createEntityManagerFactory("customer-openJPA"); + em = emf.createEntityManager(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void delete(String arg0) throws NotFoundException { + // TODO Auto-generated method stub + + } + + public Customer get(String arg0) throws NotFoundException { + // TODO Auto-generated method stub + return null; + } + + public Entry[] getAll() { + EntityTransaction tx = em.getTransaction(); + try { + tx.begin(); + + Query q = em.createQuery("SELECT c FROM customer c"); + List results = q.getResultList(); + Iterator iter = results.iterator(); + while (iter.hasNext()) { + Customer customer = (Customer)iter.next(); + + System.out.println(customer); + } + + tx.commit(); + } catch(Exception e) { + e.printStackTrace(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + + em.close(); + } + + return null; + } + + public String post(String arg0, Customer arg1) { + // TODO Auto-generated method stub + return null; + } + + public void put(String arg0, Customer arg1) throws NotFoundException { + // TODO Auto-generated method stub + + } + + public Entry[] query(String arg0) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerService.java b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerService.java new file mode 100644 index 0000000000..7915cc6e77 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerService.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 customer; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface CustomerService { + + Customer[] get(); + + Customer findCustomerByName(String name); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerServiceImpl.java new file mode 100644 index 0000000000..0cba7d8bc1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/customer/CustomerServiceImpl.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 customer; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.EntityTransaction; +import javax.persistence.Persistence; +import javax.persistence.Query; + +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; + +public class CustomerServiceImpl implements CustomerService { + EntityManagerFactory emf = null; + EntityManager em = null; + + public CustomerServiceImpl() { + + } + + @Init + public void init() { + System.out.println(">>> Initializing JPA"); + try { + emf = Persistence.createEntityManagerFactory("customer-openJPA"); + em = emf.createEntityManager(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Destroy + public void destroy() { + emf.close(); + } + + public Customer[] get() { + EntityTransaction tx = em.getTransaction(); + List customers = new ArrayList(); + try { + tx.begin(); + + Query q = em.createQuery("SELECT c FROM customer c"); + List results = q.getResultList(); + Iterator iter = results.iterator(); + while (iter.hasNext()) { + Customer customer = (Customer)iter.next(); + customers.add(customer); + } + + tx.commit(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + + em.close(); + } + + Customer[] customerArray = new Customer[customers.size()]; + customers.toArray(customerArray); + return customerArray; + } + + public Customer findCustomerByName(String name) { + EntityTransaction tx = em.getTransaction(); + Customer customer = null; + + try { + tx.begin(); + + Query q = em.createQuery("SELECT c FROM customer c WHERE c.name = '" + name + "'"); + List results = q.getResultList(); + Iterator iter = results.iterator(); + while (iter.hasNext()) { + customer = (Customer)iter.next(); + } + + tx.commit(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + + em.close(); + } + + return customer; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/launch/Launch.java b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/launch/Launch.java new file mode 100644 index 0000000000..d7f88b8dd4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/java/launch/Launch.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 launch; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class Launch { + public static void main(String[] args) throws Exception { + System.out.println("Starting ..."); + SCADomain scaDomain = SCADomain.newInstance("customer.composite"); + System.out.println("store.composite ready for big business !!!"); + System.in.read(); + System.out.println("Stopping ..."); + scaDomain.close(); + System.out.println(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/META-INF/orm.xml b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/META-INF/orm.xml new file mode 100644 index 0000000000..64be295302 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/META-INF/orm.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/META-INF/persistence.xml b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000000..7073c8daf7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,40 @@ + + + + + + + orm.xml + customer.Customer + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..136326d1d3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/content/customer.html b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/content/customer.html new file mode 100644 index 0000000000..dbc8aad9d0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/content/customer.html @@ -0,0 +1,77 @@ + + + + Tuscany Dojo JSON-RPC Customer Example + + + + + + + + + + + + + + + +

Tuscany Dojo JSON-RPC Customer Sample

+ +Customer Name :
+ + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/customer.composite b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/customer.composite new file mode 100644 index 0000000000..4c370f2a9f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/customer-dojo/src/main/resources/customer.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/README b/sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/README new file mode 100644 index 0000000000..67c1aa32d5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/databinding-echo/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/build.xml new file mode 100644 index 0000000000..7f2483f6fb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/build.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/databinding-echo.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/databinding-echo/databinding-echo.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/databinding-echo.svg b/sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/databinding-echo.svg new file mode 100644 index 0000000000..87964abf86 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/databinding-echo/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/pom.xml new file mode 100644 index 0000000000..3ef0bcfbf5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/pom.xml @@ -0,0 +1,82 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + + sample-databinding-echo + Apache Tuscany SCA Echo Data Binding Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-databinding + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + sample-binding-echo + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-wsdl-xml + 1.4-SNAPSHOT + + + + junit + junit + 4.2 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/src/main/java/dbecho/ComponentAImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/databinding-echo/src/main/java/dbecho/ComponentBImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/databinding-echo/src/main/java/dbecho/Echo.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/databinding-echo/src/main/java/dbecho/EchoDataBindingClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/databinding-echo/src/main/java/dbecho/Interface1.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/databinding-echo/src/main/java/dbecho/Interface2.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/databinding-echo/src/main/resources/EchoDataBinding.composite b/sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/src/main/resources/EchoDataBinding.composite new file mode 100644 index 0000000000..30b77a6152 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/src/main/resources/EchoDataBinding.composite @@ -0,0 +1,58 @@ + + + + + + + + ABC + + + + + + + + + + + + + + + ABC + + + BAR + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/databinding-echo/src/main/resources/wsdl/echo.wsdl b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/databinding-echo/src/test/java/dbecho/EchoDataBindingTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/domain-management/README b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/README new file mode 100644 index 0000000000..6280a28028 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/README @@ -0,0 +1,8 @@ +Domain Management Sample Tasks +============================== +This sample implements the following sample domain management tasks: +- list deployables in a contribution +- list contribution dependencies +- fuse includes in a composite +- add deployables to a domain composite and wire them + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/pom.xml new file mode 100644 index 0000000000..781f77285a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/pom.xml @@ -0,0 +1,247 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-domain-management + Apache Tuscany SCA Sample Domain Management Tasks + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-assembly + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-contribution + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-contribution-xml + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-workspace + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-workspace-xml + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-workspace-impl + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-node + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-launcher + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-extensibility + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-monitor + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-monitor-logging + 1.4-SNAPSHOT + runtime + + + + xerces + xercesImpl + 2.8.1 + + + + org.apache.tuscany.sca + tuscany-binding-atom + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-contribution-java + 1.4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-contribution-namespace + 1.4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-contribution-resource + 1.4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-xml + 1.4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-interface-java-xml + 1.4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-data-api + 1.4-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + generate + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assets + package + + single + + + + src/test/resources/assembly/assets.xml + + gnu + ${artifactId} + + + + store + package + + single + + + + src/test/resources/assembly/store.xml + + gnu + ${artifactId} + + + + client + package + + single + + + + src/test/resources/assembly/client.xml + + gnu + ${artifactId} + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java new file mode 100644 index 0000000000..28eede693d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java @@ -0,0 +1,328 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package manager; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import javax.xml.transform.TransformerFactory; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.SCABindingFactory; +import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; +import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; +import org.apache.tuscany.sca.binding.atom.AtomBindingFactory; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver; +import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.ModuleActivator; +import org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.apache.tuscany.sca.implementation.node.NodeImplementation; +import org.apache.tuscany.sca.implementation.node.NodeImplementationFactory; +import org.apache.tuscany.sca.implementation.node.builder.impl.NodeCompositeBuilderImpl; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.MonitorFactory; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.launcher.NodeLauncher; +import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory; +import org.apache.tuscany.sca.workspace.Workspace; +import org.apache.tuscany.sca.workspace.WorkspaceFactory; +import org.apache.tuscany.sca.workspace.builder.ContributionDependencyBuilder; +import org.apache.tuscany.sca.workspace.builder.impl.ContributionDependencyBuilderImpl; +import org.apache.xml.serialize.OutputFormat; +import org.apache.xml.serialize.XMLSerializer; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +/** + * Sample RunComponents task + * + * Under construction... This sample is similar to the DistributeComponents sample, + * with extra steps to configure SCA runtime nodes with the models, start and stop + * them. + * + * @version $Rev$ $Date$ + */ +public class DistributeAndRunComponents { + + private static URLArtifactProcessor contributionProcessor; + private static ModelResolverExtensionPoint modelResolvers; + private static ModelFactoryExtensionPoint modelFactories; + private static WorkspaceFactory workspaceFactory; + private static AssemblyFactory assemblyFactory; + private static XMLOutputFactory outputFactory; + private static DocumentBuilderFactory documentBuilderFactory; + private static TransformerFactory transformerFactory; + private static StAXArtifactProcessor xmlProcessor; + private static ContributionDependencyBuilder contributionDependencyBuilder; + private static CompositeBuilder domainCompositeBuilder; + private static CompositeBuilder nodeCompositeBuilder; + private static NodeImplementationFactory nodeFactory; + private static AtomBindingFactory atomBindingFactory; + + private static void init() { + + // Create extension point registry + ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + + // Create a monitor + UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); + MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); + Monitor monitor = monitorFactory.createMonitor(); + + // Initialize the Tuscany module activators + ModuleActivatorExtensionPoint moduleActivators = extensionPoints.getExtensionPoint(ModuleActivatorExtensionPoint.class); + for (ModuleActivator activator: moduleActivators.getModuleActivators()) { + activator.start(extensionPoints); + } + + // Get XML input/output factories + modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); + outputFactory = modelFactories.getFactory(XMLOutputFactory.class); + documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class); + transformerFactory = modelFactories.getFactory(TransformerFactory.class); + + // Get contribution workspace and assembly model factories + workspaceFactory = modelFactories.getFactory(WorkspaceFactory.class); + assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); + nodeFactory = modelFactories.getFactory(NodeImplementationFactory.class); + atomBindingFactory = modelFactories.getFactory(AtomBindingFactory.class); + + // Create XML artifact processors + StAXArtifactProcessorExtensionPoint xmlProcessorExtensions = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + xmlProcessor = new ExtensibleStAXArtifactProcessor(xmlProcessorExtensions, inputFactory, outputFactory, monitor); + + // Create contribution content processor + URLArtifactProcessorExtensionPoint docProcessorExtensions = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); + contributionProcessor = docProcessorExtensions.getProcessor(Contribution.class); + + // Get the model resolvers + modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); + + // Create a contribution dependency builder + contributionDependencyBuilder = new ContributionDependencyBuilderImpl(monitor); + + // Create a composite builder + SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class); + IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class); + InterfaceContractMapper contractMapper = utilities.getUtility(InterfaceContractMapper.class); + domainCompositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, + documentBuilderFactory, transformerFactory, contractMapper, monitor); + + // Create a node composite builder + nodeCompositeBuilder = new NodeCompositeBuilderImpl(assemblyFactory, scaBindingFactory, + documentBuilderFactory, transformerFactory, contractMapper, null, monitor); + } + + + public static void main(String[] args) throws Exception { + init(); + + // Create workspace model + Workspace workspace = workspaceFactory.createWorkspace(); + workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories)); + + // Read the sample store contribution + URI storeURI = URI.create("store"); + URL storeURL = new File("./target/sample-domain-management-store.jar").toURI().toURL(); + Contribution storeContribution = contributionProcessor.read(null, storeURI, storeURL); + workspace.getContributions().add(storeContribution); + + // Read the sample assets contribution + URI assetsURI = URI.create("assets"); + URL assetsURL = new File("./target/sample-domain-management-assets.jar").toURI().toURL(); + Contribution assetsContribution = contributionProcessor.read(null, assetsURI, assetsURL); + workspace.getContributions().add(assetsContribution); + + // Read the sample client contribution + URI clientURI = URI.create("client"); + URL clientURL = new File("./target/sample-domain-management-client.jar").toURI().toURL(); + Contribution clientContribution = contributionProcessor.read(null, clientURI, clientURL); + workspace.getContributions().add(clientContribution); + + // Build the contribution dependencies + Map> contributionDependencies = new HashMap>(); + Set resolved = new HashSet(); + for (Contribution contribution: workspace.getContributions()) { + List dependencies = contributionDependencyBuilder.buildContributionDependencies(contribution, workspace); + + // Resolve contributions + for (Contribution dependency: dependencies) { + if (!resolved.contains(dependency)) { + resolved.add(dependency); + contributionProcessor.resolve(dependency, workspace.getModelResolver()); + } + } + + contributionDependencies.put(contribution, dependencies); + } + + // Create a set of nodes, and assign the sample deployables to them + Map> nodeDependencies = new HashMap>(); + Composite cloudComposite = assemblyFactory.createComposite(); + cloudComposite.setName(new QName("http://sample", "cloud")); + int nodeID = 8100; + for (Contribution contribution: workspace.getContributions()) { + for (Composite deployable: contribution.getDeployables()) { + + // Create a node + Component node = assemblyFactory.createComponent(); + node.setName("Node" + nodeID); + cloudComposite.getComponents().add(node); + + // Add default binding configuration to the node, our samples use + // Atom bindings so here we're just creating default Atom binding + // configurations, but all the other binding types can be configured + // like that too + ComponentService nodeService = assemblyFactory.createComponentService(); + Binding binding = atomBindingFactory.createAtomBinding(); + binding.setURI("http://localhost:" + (8100 + nodeID)); + nodeService.getBindings().add(binding); + node.getServices().add(nodeService); + + // Assign a deployable to the node + NodeImplementation nodeImplementation = nodeFactory.createNodeImplementation(); + nodeImplementation.setComposite(deployable); + node.setImplementation(nodeImplementation); + + // Keep track of what contributions will be needed by the node + nodeDependencies.put(node, contributionDependencies.get(contribution)); + + nodeID++; + } + } + + // Print the model describing the nodes that we just built + System.out.println("cloud.composite"); + System.out.println(print(cloudComposite)); + + // Build the nodes, this will apply their default binding configuration to the + // composites assigned to them + nodeCompositeBuilder.build(cloudComposite); + + // Create a composite model for the domain + Composite domainComposite = assemblyFactory.createComposite(); + domainComposite.setName(new QName("http://sample", "domain")); + + // Add all deployables to it, normally the domain administrator would select + // the deployables to include + domainComposite.getIncludes().addAll(workspace.getDeployables()); + + // Build the domain composite and wire the components included in it + domainCompositeBuilder.build(domainComposite); + + // Print out the resulting domain composite + System.out.println("domain.composite"); + System.out.println(print(domainComposite)); + + // Now start our SCA nodes + List runtimeNodes = new ArrayList(); + NodeLauncher launcher = NodeLauncher.newInstance(); + for (Component node: cloudComposite.getComponents()) { + + // Create a composite containing the components that we want to run + // on the node + Composite runnable = assemblyFactory.createComposite(); + runnable.setName(new QName("http://sample", node.getName())); + NodeImplementation nodeImplementation = (NodeImplementation)node.getImplementation(); + for (Component component: nodeImplementation.getComposite().getComponents()) { + for (Component configured: domainComposite.getComponents()) { + if (configured.getName().equals(component.getName())) { + runnable.getComponents().add(configured); + break; + } + } + } + + // Create the SCA node, give it the composite and the list of contributions + // to use + List dependencies = nodeDependencies.get(node); + org.apache.tuscany.sca.node.launcher.Contribution[] contributions = new org.apache.tuscany.sca.node.launcher.Contribution[dependencies.size()]; + for (int c =0, n = dependencies.size(); c < n; c++) { + Contribution dependency = dependencies.get(c); + contributions[c] = new org.apache.tuscany.sca.node.launcher.Contribution(dependency.getURI(), dependency.getLocation()); + } + SCANode runtimeNode = launcher.createNode("http://sample/" + node.getName(), print(runnable), contributions); + + // Start the node + runtimeNode.start(); + runtimeNodes.add(runtimeNode); + } + + System.out.println("Nodes are running, press enter to stop..."); + System.in.read(); + + for (SCANode runtimeNode: runtimeNodes) { + runtimeNode.stop(); + } + } + + private static String print(Composite composite) throws XMLStreamException, ContributionWriteException, ParserConfigurationException, SAXException, IOException { + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + XMLStreamWriter writer = outputFactory.createXMLStreamWriter(bos); + xmlProcessor.write(composite, writer); + + // Parse and write again to pretty format it + DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document document = documentBuilder.parse(new ByteArrayInputStream(bos.toByteArray())); + OutputFormat format = new OutputFormat(); + format.setIndenting(true); + format.setIndent(2); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + XMLSerializer serializer = new XMLSerializer(out, format); + serializer.serialize(document); + return out.toString(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/DistributeComponents.java b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/DistributeComponents.java new file mode 100644 index 0000000000..def0a1894f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/DistributeComponents.java @@ -0,0 +1,288 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package manager; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URL; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import javax.xml.transform.TransformerFactory; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.SCABindingFactory; +import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; +import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; +import org.apache.tuscany.sca.binding.atom.AtomBindingFactory; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.ContributionFactory; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver; +import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.ModuleActivator; +import org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.apache.tuscany.sca.implementation.node.NodeImplementation; +import org.apache.tuscany.sca.implementation.node.NodeImplementationFactory; +import org.apache.tuscany.sca.implementation.node.builder.impl.NodeCompositeBuilderImpl; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.MonitorFactory; +import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory; +import org.apache.tuscany.sca.policy.PolicyFactory; +import org.apache.tuscany.sca.workspace.Workspace; +import org.apache.tuscany.sca.workspace.WorkspaceFactory; +import org.apache.tuscany.sca.workspace.builder.ContributionDependencyBuilder; +import org.apache.tuscany.sca.workspace.builder.impl.ContributionDependencyBuilderImpl; +import org.apache.xml.serialize.OutputFormat; +import org.apache.xml.serialize.XMLSerializer; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +/** + * Sample DistributeComponents task + * + * This sample shows how to use a subset of Tuscany to read contribution + * metadata, analyze and resolve contribution dependencies, read and resolve + * the artifacts that they contribute (in particular implementation artifacts, + * interfaces, composites, componentTypes etc.) and assembe and wire the + * deployable composites together in a composite model representing an SCA + * domain composite. + * + * The difference between this sample and the WireComponents sample is an + * extra step to allocate deployable composites to SCA nodes. SCA nodes allow + * you to provide default configuration for the deploayable composites allocated + * to them, for example default binding configuration. + * + * The sample first reads the SCA metadata for three sample contributions, + * reads and resolve the artifacts contained in the contributions, includes all their + * deployable composites in a composite model representing an SCA domain, then + * uses several composite builder utilities to configure them as specified in the + * SCA nodes hosting them and assemble and wire them together. + * Finally it prints the resulting domain composite model, showing service bindings + * configured with the URIs from the nodes hosting them. + * + * @version $Rev$ $Date$ + */ +public class DistributeComponents { + + private static URLArtifactProcessor contributionProcessor; + private static ModelResolverExtensionPoint modelResolvers; + private static ModelFactoryExtensionPoint modelFactories; + private static WorkspaceFactory workspaceFactory; + private static AssemblyFactory assemblyFactory; + private static XMLOutputFactory outputFactory; + private static DocumentBuilderFactory documentBuilderFactory; + private static TransformerFactory transformerFactory; + private static StAXArtifactProcessor xmlProcessor; + private static ContributionDependencyBuilder contributionDependencyBuilder; + private static CompositeBuilder domainCompositeBuilder; + private static CompositeBuilder nodeCompositeBuilder; + private static NodeImplementationFactory nodeFactory; + private static AtomBindingFactory atomBindingFactory; + + private static void init() { + + // Create extension point registry + ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + + // Create a monitor + UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); + MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); + Monitor monitor = monitorFactory.createMonitor(); + + // Initialize the Tuscany module activators + ModuleActivatorExtensionPoint moduleActivators = extensionPoints.getExtensionPoint(ModuleActivatorExtensionPoint.class); + for (ModuleActivator activator: moduleActivators.getModuleActivators()) { + activator.start(extensionPoints); + } + + // Get XML input/output factories + modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); + outputFactory = modelFactories.getFactory(XMLOutputFactory.class); + documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class); + transformerFactory = modelFactories.getFactory(TransformerFactory.class); + + // Get contribution workspace and assembly model factories + workspaceFactory = modelFactories.getFactory(WorkspaceFactory.class); + assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); + nodeFactory = modelFactories.getFactory(NodeImplementationFactory.class); + atomBindingFactory = modelFactories.getFactory(AtomBindingFactory.class); + + // Create XML artifact processors + StAXArtifactProcessorExtensionPoint xmlProcessorExtensions = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + xmlProcessor = new ExtensibleStAXArtifactProcessor(xmlProcessorExtensions, inputFactory, outputFactory, monitor); + + // Create contribution content processor + URLArtifactProcessorExtensionPoint docProcessorExtensions = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); + contributionProcessor = docProcessorExtensions.getProcessor(Contribution.class); + + // Get the model resolvers + modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); + + // Create a contribution dependency builder + contributionDependencyBuilder = new ContributionDependencyBuilderImpl(monitor); + + // Create a composite builder + SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class); + IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class); + InterfaceContractMapper contractMapper = utilities.getUtility(InterfaceContractMapper.class); + domainCompositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, + documentBuilderFactory, transformerFactory, contractMapper, monitor); + + // Create a node composite builder + nodeCompositeBuilder = new NodeCompositeBuilderImpl(assemblyFactory, scaBindingFactory, + documentBuilderFactory, transformerFactory, contractMapper, null, monitor); + } + + + public static void main(String[] args) throws Exception { + init(); + + // Create workspace model + Workspace workspace = workspaceFactory.createWorkspace(); + workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories)); + + // Read the sample store contribution + URI storeURI = URI.create("store"); + URL storeURL = new File("./target/sample-domain-management-store.jar").toURI().toURL(); + Contribution storeContribution = contributionProcessor.read(null, storeURI, storeURL); + workspace.getContributions().add(storeContribution); + + // Read the sample assets contribution + URI assetsURI = URI.create("assets"); + URL assetsURL = new File("./target/sample-domain-management-assets.jar").toURI().toURL(); + Contribution assetsContribution = contributionProcessor.read(null, assetsURI, assetsURL); + workspace.getContributions().add(assetsContribution); + + // Read the sample client contribution + URI clientURI = URI.create("client"); + URL clientURL = new File("./target/sample-domain-management-client.jar").toURI().toURL(); + Contribution clientContribution = contributionProcessor.read(null, clientURI, clientURL); + workspace.getContributions().add(clientContribution); + + // Build the contribution dependencies + Set resolved = new HashSet(); + for (Contribution contribution: workspace.getContributions()) { + List dependencies = contributionDependencyBuilder.buildContributionDependencies(contribution, workspace); + + // Resolve contributions + for (Contribution dependency: dependencies) { + if (!resolved.contains(dependency)) { + resolved.add(dependency); + contributionProcessor.resolve(dependency, workspace.getModelResolver()); + } + } + } + + // Create a set of nodes, and assign the sample deployables to them + Composite cloudComposite = assemblyFactory.createComposite(); + cloudComposite.setName(new QName("http://sample", "cloud")); + for (int i = 0, n = workspace.getDeployables().size(); i < n; i++) { + + // Create a node + Component node = assemblyFactory.createComponent(); + node.setName("Node" + i); + cloudComposite.getComponents().add(node); + + // Add default binding configuration to the node, our samples use + // Atom bindings so here we're just creating default Atom binding + // configurations, but all the other binding types can be configured + // like that too + ComponentService nodeService = assemblyFactory.createComponentService(); + Binding binding = atomBindingFactory.createAtomBinding(); + binding.setURI("http://localhost:" + (8100 + i)); + nodeService.getBindings().add(binding); + node.getServices().add(nodeService); + + // Assign a deployable to the node + NodeImplementation nodeImplementation = nodeFactory.createNodeImplementation(); + Composite deployable = workspace.getDeployables().get(i); + nodeImplementation.setComposite(deployable); + node.setImplementation(nodeImplementation); + } + + // Print the model describing the nodes that we just built + System.out.println("cloud.composite"); + print(cloudComposite); + System.out.println(); + + // Build the nodes, this will apply their default binding configuration to the + // composites assigned to them + nodeCompositeBuilder.build(cloudComposite); + + // Create a composite model for the domain + Composite domainComposite = assemblyFactory.createComposite(); + domainComposite.setName(new QName("http://sample", "domain")); + + // Add all deployables to it, normally the domain administrator would select + // the deployables to include + domainComposite.getIncludes().addAll(workspace.getDeployables()); + + // Build the domain composite and wire the components included in it + domainCompositeBuilder.build(domainComposite); + + // Print out the resulting domain composite + System.out.println("domain.composite"); + print(domainComposite); + } + + private static void print(Composite composite) throws XMLStreamException, ContributionWriteException, ParserConfigurationException, SAXException, IOException { + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + XMLStreamWriter writer = outputFactory.createXMLStreamWriter(bos); + xmlProcessor.write(composite, writer); + + // Parse and write again to pretty format it + DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document document = documentBuilder.parse(new ByteArrayInputStream(bos.toByteArray())); + OutputFormat format = new OutputFormat(); + format.setIndenting(true); + format.setIndent(2); + XMLSerializer serializer = new XMLSerializer(System.out, format); + serializer.serialize(document); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/ListComponents.java b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/ListComponents.java new file mode 100644 index 0000000000..27cb31d57f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/ListComponents.java @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package manager; + +import java.io.File; +import java.net.URI; +import java.net.URL; +import java.util.List; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver; +import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.ModuleActivator; +import org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.MonitorFactory; +import org.apache.tuscany.sca.workspace.Workspace; +import org.apache.tuscany.sca.workspace.WorkspaceFactory; +import org.apache.tuscany.sca.workspace.builder.ContributionDependencyBuilder; +import org.apache.tuscany.sca.workspace.builder.impl.ContributionDependencyBuilderImpl; + +/** + * Sample ListComponents task. + * + * This sample shows how to use subset of Tuscany to read contribution + * metadata, analyze and resolve contribution dependencies, read and resolve + * the artifacts that they contribute (in particular implementation artifacts, + * interfaces, composites and componentTypes). + * + * The sample first reads the SCA metadata for two sample contributions, then displays + * their dependencies, reads and resolve the artifacts contained in the contributions, + * and finally prints the deployables composites and the components they declare as + * well as their main characteristics (showing that their interfaces and implementations + * for example are actually resolved). + * + * @version $Rev$ $Date$ + */ +public class ListComponents { + + private static URLArtifactProcessor contributionProcessor; + private static ModelResolverExtensionPoint modelResolvers; + private static ModelFactoryExtensionPoint modelFactories; + private static WorkspaceFactory workspaceFactory; + private static ContributionDependencyBuilder contributionDependencyBuilder; + + private static void init() { + + // Create extension point registry + ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + + // Initialize the Tuscany module activators + ModuleActivatorExtensionPoint moduleActivators = extensionPoints.getExtensionPoint(ModuleActivatorExtensionPoint.class); + for (ModuleActivator activator: moduleActivators.getModuleActivators()) { + activator.start(extensionPoints); + } + + // Get workspace contribution factory + modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + workspaceFactory = modelFactories.getFactory(WorkspaceFactory.class); + + // Create contribution content processor + URLArtifactProcessorExtensionPoint docProcessorExtensions = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); + contributionProcessor = docProcessorExtensions.getProcessor(Contribution.class); + + // Get the model resolvers + modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); + + // Create a monitor + UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); + MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); + Monitor monitor = monitorFactory.createMonitor(); + + // Create a contribution dependency builder + contributionDependencyBuilder = new ContributionDependencyBuilderImpl(monitor); + } + + + public static void main(String[] args) throws Exception { + init(); + + // Create workspace model + Workspace workspace = workspaceFactory.createWorkspace(); + workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories)); + + // Read the sample store contribution + URI storeURI = URI.create("store"); + URL storeURL = new File("./target/sample-domain-management-store.jar").toURI().toURL(); + Contribution storeContribution = contributionProcessor.read(null, storeURI, storeURL); + workspace.getContributions().add(storeContribution); + + // Read the sample assets contribution + URI assetsURI = URI.create("assets"); + URL assetsURL = new File("./target/sample-domain-management-assets.jar").toURI().toURL(); + Contribution assetsContribution = contributionProcessor.read(null, assetsURI, assetsURL); + workspace.getContributions().add(assetsContribution); + + // Build the store contribution dependencies + List dependencies = contributionDependencyBuilder.buildContributionDependencies(storeContribution, workspace); + + // Resolve the contributions + for (Contribution contribution: dependencies) { + contributionProcessor.resolve(contribution, workspace.getModelResolver()); + } + + // List the components declared in the deployables found in the + // contribution, their services, bindings, interfaces, and implementations + for (Composite deployable: storeContribution.getDeployables()) { + System.out.println("Deployable: " + deployable.getName()); + for (Component component: deployable.getComponents()) { + System.out.println(" component: " + component.getName()); + for (ComponentService componentService: component.getServices()) { + System.out.println(" componentService: " + componentService.getName()); + for (Binding binding: componentService.getBindings()) { + System.out.println(" binding: " + binding.getClass() + " - " + binding.getURI()); + } + } + Implementation implementation = component.getImplementation(); + System.out.println(" implementation: " + implementation); + for (Service service: implementation.getServices()) { + System.out.println(" service: " + service.getName()); + InterfaceContract contract = service.getInterfaceContract(); + System.out.println(" interface: " + contract.getInterface()); + } + } + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/ListDependencies.java b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/ListDependencies.java new file mode 100644 index 0000000000..1bf8124682 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/ListDependencies.java @@ -0,0 +1,108 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package manager; + +import java.io.File; +import java.net.URI; +import java.net.URL; + +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.MonitorFactory; +import org.apache.tuscany.sca.workspace.Workspace; +import org.apache.tuscany.sca.workspace.WorkspaceFactory; +import org.apache.tuscany.sca.workspace.builder.ContributionDependencyBuilder; +import org.apache.tuscany.sca.workspace.builder.impl.ContributionDependencyBuilderImpl; + +/** + * Sample ListDependencies task. + * + * This sample shows how to use a subset of Tuscany to read contribution + * metadata, analyze and resolve contribution dependencies given a set of + * available contributions. + * + * The sample reads the SCA metadata for two sample contributions then + * prints their dependencies. + * + * @version $Rev$ $Date$ + */ +public class ListDependencies { + + private static URLArtifactProcessor contributionProcessor; + private static WorkspaceFactory workspaceFactory; + private static ContributionDependencyBuilder contributionDependencyBuilder; + + private static void init() throws Exception { + + // Create extension point registry + ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + + // Get contribution, workspace and assembly model factories + ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + workspaceFactory = modelFactories.getFactory(WorkspaceFactory.class); + + // Create contribution info processor + URLArtifactProcessorExtensionPoint docProcessorExtensions = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); + contributionProcessor = docProcessorExtensions.getProcessor(Contribution.class); + + // Create a monitor + UtilityExtensionPoint services = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); + MonitorFactory monitorFactory = services.getUtility(MonitorFactory.class); + Monitor monitor = monitorFactory.createMonitor(); + + // Create a contribution dependency builder + contributionDependencyBuilder = new ContributionDependencyBuilderImpl(monitor); + } + + + public static void main(String[] args) throws Exception { + init(); + + // Create workspace model + Workspace workspace = workspaceFactory.createWorkspace(); + + // Read the contribution info for the sample contribution + URI storeURI = URI.create("store"); + URL storeURL = new File("./target/sample-domain-management-store.jar").toURI().toURL(); + Contribution storeContribution = (Contribution)contributionProcessor.read(null, storeURI, storeURL); + workspace.getContributions().add(storeContribution); + + // Read the contribution info for the assets contribution + URI assetsURI = URI.create("assets"); + URL assetsURL = new File("./target/sample-domain-management-assets.jar").toURI().toURL(); + Contribution assetsContribution = contributionProcessor.read(null, assetsURI, assetsURL); + workspace.getContributions().add(assetsContribution); + + // List the contribution dependencies of each contribution + for (Contribution contribution: workspace.getContributions()) { + System.out.println("Contribution: " + contribution.getURI()); + for (Contribution dependency: contributionDependencyBuilder.buildContributionDependencies(contribution, workspace)) { + System.out.println(" dependency: " + dependency.getURI()); + } + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/ListDeployables.java b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/ListDeployables.java new file mode 100644 index 0000000000..f5f0b9c655 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/ListDeployables.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 manager; + +import java.io.File; +import java.net.URI; +import java.net.URL; + +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; + +/** + * Sample ListDeployables task. + * + * This sample shows how to use a subset of Tuscany to read contribution + * metadata. + * + * The sample reads the SCA metadata for two sample contributions then + * prints the names of their deployable composites. + * + * @version $Rev$ $Date$ + */ +public class ListDeployables { + + private static URLArtifactProcessor contributionProcessor; + + private static void init() { + + // Create extension point registry + ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + + // Create contribution info processor + URLArtifactProcessorExtensionPoint docProcessorExtensions = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); + contributionProcessor = docProcessorExtensions.getProcessor(Contribution.class); + } + + public static void main(String[] args) throws Exception { + init(); + + // Read the contribution info for the sample contribution + URI uri = URI.create("store"); + URL url = new File("./target/sample-domain-management-store.jar").toURI().toURL(); + Contribution contribution = contributionProcessor.read(null, uri, url); + + // List the deployables in the contribution + for (Composite deployable: contribution.getDeployables()) { + System.out.println("Deployable: " + deployable.getName()); + } + + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/WireComponents.java b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/WireComponents.java new file mode 100644 index 0000000000..d24d5c67c9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/main/java/manager/WireComponents.java @@ -0,0 +1,218 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package manager; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.net.URI; +import java.net.URL; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamWriter; +import javax.xml.transform.TransformerFactory; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.SCABindingFactory; +import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; +import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver; +import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.ModuleActivator; +import org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.MonitorFactory; +import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory; +import org.apache.tuscany.sca.workspace.Workspace; +import org.apache.tuscany.sca.workspace.WorkspaceFactory; +import org.apache.tuscany.sca.workspace.builder.ContributionDependencyBuilder; +import org.apache.tuscany.sca.workspace.builder.impl.ContributionDependencyBuilderImpl; +import org.apache.xml.serialize.OutputFormat; +import org.apache.xml.serialize.XMLSerializer; +import org.w3c.dom.Document; + +/** + * Sample WireComponents task. + * + * This sample shows how to use a subset of Tuscany to read contribution + * metadata, analyze and resolve contribution dependencies, read and resolve + * the artifacts that they contribute (in particular implementation artifacts, + * interfaces, composites, componentTypes etc.) and assembe and wire the + * deployable composites together in a composite model representing an SCA + * domain composite. + * + * The sample first reads the SCA metadata for three sample contributions, + * reads and resolve the artifacts contained in the contributions, includes all their + * deployable composites in a composite model representing an SCA domain, then + * uses a composite builder utility to assemble and wire the composites together. + * Finally it prints the resulting domain composite model. + * + * @version $Rev$ $Date$ + */ +public class WireComponents { + + private static URLArtifactProcessor contributionProcessor; + private static ModelResolverExtensionPoint modelResolvers; + private static ModelFactoryExtensionPoint modelFactories; + private static WorkspaceFactory workspaceFactory; + private static AssemblyFactory assemblyFactory; + private static XMLOutputFactory outputFactory; + private static DocumentBuilderFactory documentBuilderFactory; + private static TransformerFactory transformerFactory; + private static StAXArtifactProcessor xmlProcessor; + private static ContributionDependencyBuilder contributionDependencyBuilder; + private static CompositeBuilder domainCompositeBuilder; + + private static void init() { + + // Create extension point registry + ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + + // Create a monitor + UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); + MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); + Monitor monitor = monitorFactory.createMonitor(); + + // Initialize the Tuscany module activators + ModuleActivatorExtensionPoint moduleActivators = extensionPoints.getExtensionPoint(ModuleActivatorExtensionPoint.class); + for (ModuleActivator activator: moduleActivators.getModuleActivators()) { + activator.start(extensionPoints); + } + + // Get XML input/output factories + modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); + outputFactory = modelFactories.getFactory(XMLOutputFactory.class); + documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class); + transformerFactory = modelFactories.getFactory(TransformerFactory.class); + + // Get contribution workspace and assembly model factories + workspaceFactory = modelFactories.getFactory(WorkspaceFactory.class); + assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); + + // Create XML artifact processors + StAXArtifactProcessorExtensionPoint xmlProcessorExtensions = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + xmlProcessor = new ExtensibleStAXArtifactProcessor(xmlProcessorExtensions, inputFactory, outputFactory, monitor); + + // Create contribution content processor + URLArtifactProcessorExtensionPoint docProcessorExtensions = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); + contributionProcessor = docProcessorExtensions.getProcessor(Contribution.class); + + // Get the model resolvers + modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); + + // Create a contribution dependency builder + contributionDependencyBuilder = new ContributionDependencyBuilderImpl(monitor); + + // Create a composite builder + SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class); + IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class); + InterfaceContractMapper contractMapper = utilities.getUtility(InterfaceContractMapper.class); + domainCompositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, + documentBuilderFactory, transformerFactory, contractMapper, monitor); + + } + + + public static void main(String[] args) throws Exception { + init(); + + // Create workspace model + Workspace workspace = workspaceFactory.createWorkspace(); + workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories)); + + // Read the sample store contribution + URI storeURI = URI.create("store"); + URL storeURL = new File("./target/sample-domain-management-store.jar").toURI().toURL(); + Contribution storeContribution = contributionProcessor.read(null, storeURI, storeURL); + workspace.getContributions().add(storeContribution); + + // Read the sample assets contribution + URI assetsURI = URI.create("assets"); + URL assetsURL = new File("./target/sample-domain-management-assets.jar").toURI().toURL(); + Contribution assetsContribution = contributionProcessor.read(null, assetsURI, assetsURL); + workspace.getContributions().add(assetsContribution); + + // Read the sample client contribution + URI clientURI = URI.create("client"); + URL clientURL = new File("./target/sample-domain-management-client.jar").toURI().toURL(); + Contribution clientContribution = contributionProcessor.read(null, clientURI, clientURL); + workspace.getContributions().add(clientContribution); + + // Build the contribution dependencies + Set resolved = new HashSet(); + for (Contribution contribution: workspace.getContributions()) { + List dependencies = contributionDependencyBuilder.buildContributionDependencies(contribution, workspace); + + // Resolve contributions + for (Contribution dependency: dependencies) { + if (!resolved.contains(dependency)) { + resolved.add(dependency); + contributionProcessor.resolve(contribution, workspace.getModelResolver()); + } + } + } + + // Create a composite model for the domain + Composite domainComposite = assemblyFactory.createComposite(); + domainComposite.setName(new QName("http://sample", "domain")); + + // Add all deployables to it, normally the domain administrator would select + // the deployables to include + domainComposite.getIncludes().addAll(workspace.getDeployables()); + + // Build the domain composite and wire the components included in it + domainCompositeBuilder.build(domainComposite); + + // Print out the resulting domain composite + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + XMLStreamWriter writer = outputFactory.createXMLStreamWriter(bos); + xmlProcessor.write(domainComposite, writer); + + // Parse and write again to pretty format it + DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document document = documentBuilder.parse(new ByteArrayInputStream(bos.toByteArray())); + OutputFormat format = new OutputFormat(); + format.setIndenting(true); + format.setIndent(2); + XMLSerializer serializer = new XMLSerializer(System.out, format); + serializer.serialize(document); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/Cart.java b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/Cart.java new file mode 100644 index 0000000000..9e6226d963 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/Cart.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import org.apache.tuscany.sca.data.collection.Collection; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Cart extends Collection { + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/Item.java b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/Item.java new file mode 100644 index 0000000000..81cefcdbef --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/Item.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + + +public class Item { + private String name; + private String price; + private String origin; + + public Item() { + } + + public Item(String name, String price, String origin) { + this.name = name; + this.price = price; + this.origin = origin; + } + + public Item(String name, String price) { + this.name = name; + this.price = price; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPrice() { + return price; + } + + public void setPrice(String price) { + this.price = price; + } + + public String getOrigin() { + return origin; + } + + public void setOrigin(String origin) { + this.origin = origin; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/ShoppingCartClientImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/ShoppingCartClientImpl.java new file mode 100644 index 0000000000..c32853b3a9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/ShoppingCartClientImpl.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import org.apache.tuscany.sca.data.collection.Entry; +import org.apache.tuscany.sca.data.collection.NotFoundException; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +@Scope("COMPOSITE") +public class ShoppingCartClientImpl implements Cart { + + @Reference + public Cart cart; + + public Entry[] getAll() { + return cart.getAll(); + } + + public Item get(String key) throws NotFoundException { + return cart.get(key); + } + + public String post(String key, Item item) { + return cart.post(key, item); + } + + public void put(String key, Item item) throws NotFoundException { + cart.put(key, item); + } + + public void delete(String key) throws NotFoundException { + cart.delete(key); + } + + public Entry[] query(String queryString) { + return cart.query(queryString); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/ShoppingCartImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/ShoppingCartImpl.java new file mode 100644 index 0000000000..30abfe77a0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/java/services/ShoppingCartImpl.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 services; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.tuscany.sca.data.collection.Entry; +import org.apache.tuscany.sca.data.collection.NotFoundException; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; + +@Scope("COMPOSITE") +public class ShoppingCartImpl implements Cart { + + private Map cart; + + @Init + public void init() { + cart = new HashMap(); + } + + public Entry[] getAll() { + Entry[] entries = new Entry[cart.size()]; + int i = 0; + for (Map.Entry e: cart.entrySet()) { + entries[i++] = new Entry(e.getKey(), e.getValue()); + } + return entries; + } + + public Item get(String key) throws NotFoundException { + Item item = cart.get(key); + if (item == null) { + throw new NotFoundException(key); + } else { + return item; + } + } + + public String post(String key, Item item) { + if (key == null) { + key ="cart-" + UUID.randomUUID().toString(); + } + cart.put(key, item); + return key; + } + + public void put(String key, Item item) throws NotFoundException { + if (!cart.containsKey(key)) { + throw new NotFoundException(key); + } + cart.put(key, item); + } + + public void delete(String key) throws NotFoundException { + if (key == null || key.equals("")) { + cart.clear(); + } else { + Item item = cart.remove(key); + if (item == null) + throw new NotFoundException(key); + } + } + + public Entry[] query(String queryString) { + List> entries = new ArrayList>(); + if (queryString.startsWith("name=")) { + String name = queryString.substring(5); + for (Map.Entry e: cart.entrySet()) { + Item item = e.getValue(); + if (item.getName().equals(name)) { + entries.add(new Entry(e.getKey(), e.getValue())); + } + } + } + return entries.toArray(new Entry[entries.size()]); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assembly/assets.xml b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assembly/assets.xml new file mode 100644 index 0000000000..10693a89e6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assembly/assets.xml @@ -0,0 +1,38 @@ + + + + assets + false + + jar + + + + + target/test-classes/assets + / + + + target/test-classes/services + /services + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assembly/client.xml b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assembly/client.xml new file mode 100644 index 0000000000..5b34693bee --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assembly/client.xml @@ -0,0 +1,34 @@ + + + + client + false + + jar + + + + + target/test-classes/client + / + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assembly/store.xml b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assembly/store.xml new file mode 100644 index 0000000000..d19b7eb161 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assembly/store.xml @@ -0,0 +1,34 @@ + + + + store + false + + jar + + + + + target/test-classes/store + / + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assets/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assets/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..33fe814c3a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/assets/META-INF/sca-contribution.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/client/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/client/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..14e1cdb672 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/client/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-20080910/samples/domain-management/src/test/resources/client/client.composite b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/client/client.composite new file mode 100644 index 0000000000..1279b319c4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/client/client.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/store/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/store/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..52348106f2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/store/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-20080910/samples/domain-management/src/test/resources/store/store.composite b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/store/store.composite new file mode 100644 index 0000000000..d4f18771d8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-management/src/test/resources/store/store.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/README b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/README new file mode 100644 index 0000000000..c01a0dd39a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/README @@ -0,0 +1,310 @@ +Domain Webapp Sample +==================== + +Not actually a webapp just yet as webapp host need to use the new domain for it to work. +If you run the DomainServer in a debugger you will get a server that provides a registry +for servide URLs, listens for Nodes starting and stopping and provides a web page where +you can see what nodes are registered and pull up their web pages. + +Use the nodes from the calculator-distributed to register with this domain + + +========================================== +Below copied from calculator sample as a template for when this gets done + + +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-20080910/samples/domain-webapp/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/build.xml new file mode 100644 index 0000000000..e008e3c9f0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/build.xml @@ -0,0 +1,296 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/pom.xml new file mode 100644 index 0000000000..58fa5a7458 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/pom.xml @@ -0,0 +1,101 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-samples + 1.4-SNAPSHOT + ../pom.xml + + sample-domain-webapp + Apache Tuscany SCA Domain Webapp Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-domain-impl + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-sca-axis2 + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-http + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-resource + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/java/node/DomainServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/java/node/DomainServer.java new file mode 100644 index 0000000000..ea3cddc01b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/java/node/DomainServer.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 node; + +import java.io.IOException; + + +/** + * 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 DomainServer { + + public static void main(String[] args) { + try { +/* + NodeImpl node = new NodeImpl(); + node.start(); + node.getContributionManager().startContribution(DomainServer.class.getClassLoader().getResource(".")); + + try { + System.out.println("Domain server started (press enter to shutdown)"); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + node.stop(); + System.out.println("Domain server stopped"); +*/ + } catch (Exception ex) { + System.out.println("Exception in domain server " + + ex.toString()); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/META-INF/sca-contribution.xml new file mode 100755 index 0000000000..fbe5880db6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/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-20080910/samples/domain-webapp/src/main/resources/domain.composite b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/domain.composite new file mode 100644 index 0000000000..dbaaebd3c7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/domain.composite @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/webroot/index.html b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/webroot/index.html new file mode 100644 index 0000000000..425bd73734 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/webroot/index.html @@ -0,0 +1,354 @@ + + + +Apache Tuscany Domain + + + + + + + + + + + + +

Apache Tuscany Domain

+
+ +

Domain Name:

+ +
+ +

+ +

+ + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/webroot/node.png b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/webroot/node.png new file mode 100644 index 0000000000..b3c949d224 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/webroot/node.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/webroot/style.css b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/webroot/style.css new file mode 100644 index 0000000000..f5bbf23379 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/domain-webapp/src/main/resources/webroot/style.css @@ -0,0 +1,176 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +p,table,li,h1,h2,h3 +{ +font-family: verdana, arial, 'sans serif'; +} + +p, h1, h2, h3, table, li, hr +{ +margin-left: 10pt; +} + +table +{ +border-color: black; +border-collapse: separate; +border-spacing: 0px 1px; + +margin-right: 10pt; +margin-left: 10pt; +width: 800px; +} + +.sourceDetailsTable +{ +width: 600px; +} + +tr, td +{ +margin-left: 0pt; +margin-right: 0pt; +padding-left: 10pt; +font-size: 90%; +} + +p,li,th +{ +font-size: 90%; +margin-left: 10pt; +} + +pre +{ +margin-left: 10pt; +} + +body +{ +#ffffff; +} + +h1,h2,h3,hr +{ +color: firebrick; +} + +a:link {COLOR: firebrick;} +a:visited {COLOR: firebrick;} +a:active {COLOR: navy;} + +.link +{ +COLOR: firebrick; +text-decoration: underline; +} + +.clickable +{ +cursor: pointer +} + +.unread_title +{ +font-weight: bold; +} + +.read_title +{ +font-weight: normal; +} + +.summary +{ +color: DimGrey; +} + +.hidden +{ +display: none; +} + +.source_name +{ +width: 600px; +} + +.alert_text +{ +width: 600px; +} + +.alert_data +{ +margin-left: 10px; +width: 800px; +height: 800px; +} + +.source_0 +{ +background-color: LightGreen; +} + +.source_1 +{ +background-color: LightSkyBlue; +} + +.source_2 +{ +background-color: Khaki; +} + +.source_3 +{ +background-color: LightPink; +} + +.source_4 +{ +background-color: Orange; +} + +.source_5 +{ +background-color: LightCoral; +} + +.source_6 +{ +background-color: Orchid; +} + +.source_7 +{ +background-color: Peru; +} + +.source_8 +{ +background-color: SpringGreen; +} + +.source_9 +{ +background-color: LightGrey; +} + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/README b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/README new file mode 100644 index 0000000000..3668a7705e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/README @@ -0,0 +1,55 @@ +Feed-aggregator-webapp Sample +============================= +This sample demonstrates using the Feed binding to aggregate ATOM and RSS +feeds and publish a new aggregated feed in a webapp. + +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-feed-aggregator-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-feed-aggregator-webapp + +You will then see the following displayed in your Web browser. + +http://localhost:8083/atomAggregator +http://localhost:8083/atomAggregator/atomsvc +http://localhost:8083/rssAggregator + +** Please note that if your browser is not configured correctly to receive +feed information, you will be prompted to open each file that contains the feed +information in xml. + + +Building And Running The Sample Using Ant +------------------------------------------- +With the binary distribution the sample can be built using Ant as +follows + +cd feed-aggregator-webapp +ant package + +This should result in a war file (sample-feed-aggregator-webapp.war) in the +target directory. Copy this war file to your web app deployment directory and +follow instructions at the begining of this README. + + +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 feed-aggregator-webapp +mvn + +This should result in a war file (sample-feed-aggregator-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-20080910/samples/feed-aggregator-webapp/feed-aggregator-webapp.png b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/feed-aggregator-webapp.png new file mode 100644 index 0000000000..1af95a5eff Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/feed-aggregator-webapp.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/feed-aggregator-webapp.svg b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/feed-aggregator-webapp.svg new file mode 100644 index 0000000000..a861a5c50f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/feed-aggregator-webapp.svg @@ -0,0 +1,382 @@ + + + + + + + + + + + + + image/svg+xml + + + + + + + + FeedAggregator + Sort + + newFirst = true + + RssAggregator + + + + + AtomAggregator + + + Rss Sample + Atom Sample + + + + + + + + + + Engadget + BBC + Oreilly + Apache + + + RSS Atom + sample-feed-aggregator-webapp.war + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/pom.xml new file mode 100644 index 0000000000..3176489de1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/pom.xml @@ -0,0 +1,108 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-feed-aggregator-webapp + war + Apache Tuscany SCA Atom+RSS Feed Aggregator Sample Webapp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-rss-rome + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + generate + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/java/feed/AggregatorImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/java/feed/AggregatorImpl.java new file mode 100644 index 0000000000..d4adf03851 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/java/feed/AggregatorImpl.java @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package feed; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.abdera.Abdera; +import org.apache.abdera.factory.Factory; +import org.apache.abdera.model.Document; +import org.apache.abdera.model.Entry; +import org.apache.abdera.model.Feed; +import org.apache.abdera.model.Person; +import org.apache.abdera.parser.Parser; +import org.apache.tuscany.sca.binding.atom.collection.Collection; +import org.apache.tuscany.sca.binding.atom.collection.NotFoundException; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; + +import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.feed.synd.SyndFeedImpl; +import com.sun.syndication.io.SyndFeedOutput; + +/** + * Implementation of an SCA component that aggregates several + * Atom and RSS feeds. + * + * @version $Rev$ $Date$ + */ +public class AggregatorImpl implements org.apache.tuscany.sca.binding.atom.collection.Collection { + + @Reference(required = false) + public Collection atomFeed1; + @Reference(required = false) + public Collection atomFeed2; + + @Reference(required = false) + public org.apache.tuscany.sca.binding.rss.collection.Collection rssFeed1; + @Reference(required = false) + public org.apache.tuscany.sca.binding.rss.collection.Collection rssFeed2; + + @Reference(required = false) + public Sort sort; + + @Property + public String feedTitle = "Aggregated Feed"; + @Property + public String feedDescription = "Anonymous Aggregated Feed"; + @Property + public String feedAuthor = "anonymous"; + + public Feed getFeed() { + + // Create a new Feed + Factory factory = Abdera.getNewFactory(); + Feed feed = factory.newFeed(); + feed.setTitle(feedTitle); + feed.setSubtitle(feedDescription); + Person author = factory.newAuthor(); + author.setName(feedAuthor); + feed.addAuthor(author); + feed.addLink("http://tuscany.apache.org", "alternate"); + + // Aggregate entries from atomFeed1, atomFeed2, rssFeed1 and rssFeed2 + List entries = new ArrayList(); + if (atomFeed1 != null) { + try { + entries.addAll(atomFeed1.getFeed().getEntries()); + } catch (Exception e) {} + } + if (atomFeed2 != null) { + try { + entries.addAll(atomFeed2.getFeed().getEntries()); + } catch (Exception e) {} + } + if (rssFeed1 != null) { + try { + entries.addAll(atomFeed(rssFeed1.getFeed()).getEntries()); + } catch (Exception e) {} + } + if (rssFeed2 != null) { + try { + entries.addAll(atomFeed(rssFeed2.getFeed()).getEntries()); + } catch (Exception e) {} + } + + // Sort entries by published date + if (sort != null) { + entries = sort.sort(entries); + } + + // Add the entries to the new feed + for (Entry entry: entries) { + feed.addEntry(entry); + } + + return feed; + } + + public Feed query(String queryString) { + Factory factory = Abdera.getNewFactory(); + Feed feed = factory.newFeed(); + feed.setTitle(feedTitle); + feed.setSubtitle(feedDescription); + Person author = factory.newAuthor(); + author.setName(feedAuthor); + feed.addAuthor(author); + feed.addLink("http://tuscany.apache.org", "alternate"); + + Feed allFeed = getFeed(); + if (queryString.startsWith("title=")) { + String title = queryString.substring(6); + + for (Entry entry: allFeed.getEntries()) { + if (entry.getTitle().contains(title)) { + feed.addEntry(entry); + } + } + } + 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 void put(String id, Entry entry) throws NotFoundException { + } + + /** + * Convert a ROME feed to an Abdera feed. + * + * @param romeFeed + * @return + */ + private static Feed atomFeed(SyndFeed syndFeed) { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + + syndFeed.setFeedType("atom_1.0"); + SyndFeedOutput syndOutput = new SyndFeedOutput(); + try { + syndOutput.output(syndFeed, new OutputStreamWriter(bos)); + } catch (Exception e) { + throw new RuntimeException(e); + } + Parser parser = Abdera.getNewParser(); + Document document = parser.parse(new ByteArrayInputStream(bos.toByteArray())); + + return document.getRoot(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/java/feed/Sort.java b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/java/feed/Sort.java new file mode 100644 index 0000000000..dec073c36b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/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 org.apache.abdera.model.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-20080910/samples/feed-aggregator-webapp/src/main/java/feed/SortImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/java/feed/SortImpl.java new file mode 100644 index 0000000000..f7ead126a7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/java/feed/SortImpl.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 feed; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.Date; +import java.util.List; + +import org.apache.abdera.model.Entry; +import org.osoa.sca.annotations.Property; + +/** + * Implementation of a Feed Sort service component. + * + * @version $Rev$ $Date$ + */ +public class SortImpl implements Sort { + + @Property + public boolean newFirst = true; + + @SuppressWarnings("unchecked") + public List sort(List entries) { + Entry[] entriesArray = new Entry[entries.size()]; + entriesArray = (Entry[])entries.toArray(entriesArray); + Arrays.sort(entriesArray, new Comparator() { + public int compare(final Object xObj, final Object yObj) { + Date xDate = ((Entry)xObj).getUpdated(); + Date yDate = ((Entry)yObj).getUpdated(); + 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-20080910/samples/feed-aggregator-webapp/src/main/resources/FeedAggregator.composite b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/resources/FeedAggregator.composite new file mode 100644 index 0000000000..736563098f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/resources/FeedAggregator.composite @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + RSS Aggregator Sample + + + + true + + + + + + + + + + + + Atom Aggregator Sample + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..b67fe843ca --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..dea3980e4d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + + + Apache Tuscany Feed Aggregator Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + index.html + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/webapp/index.html b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/webapp/index.html new file mode 100644 index 0000000000..7b33391a87 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator-webapp/src/main/webapp/index.html @@ -0,0 +1,32 @@ + + + + Apache Tuscany Feed Aggregator Sample + + + +

Apache Tuscany Feed Aggregator Sample

+

To read the aggregated feeds, point your Web browser to the following addresses:

+
http://localhost:8083/sample-feed-aggregator-webapp/atomAggregator +
http://localhost:8083/sample-feed-aggregator-webapp/atomAggregator/atomsvc (for the Atom service document) +
http://localhost:8083/sample-feed-aggregator-webapp/rssAggregator + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/README b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/README new file mode 100644 index 0000000000..f73baec2fd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/README @@ -0,0 +1,110 @@ +Feed Aggregator Sample +====================================== +This sample demonstrates using the Feed binding to aggregate ATOM and RSS +feeds 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 run the sample using ant, 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 launch.LaunchFeedServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-feed-aggregator.jar launch.LaunchFeedServer + +You should see the following output on the screen. + +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 + +As this point the aggregated Feeds are exposed by a web server started +automatically by the SCA runtime. You can later stop the server by pressing enter. + +Now that the server is started you can point your Web browser to each URL of the +aggregated feeds to see the information in your broswer. These URLs are: + +http://localhost:8083/atomAggregator +http://localhost:8083/atomAggregator/atomsvc +http://localhost:8083/rssAggregator + +** Please note that if your browser is not configured correctly to receive +feed information, you will be prompted to open each file that contains the feed +information in xml. + +Sample Overview +--------------- +The sample provides a single component exposing a Web resource. + +web-resource/ + src/ + main/ + java/ + feed/ + AggregatorImpl.java - implementation of the Feed + aggregator component + Sort.java - utilty interface + SortImpl.java - implementation of the Sort component + launch + LaunchFeedServer.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 + + +Details of how this sample works +-------------------------------- +1. AggregatorImpl is used to implement the two main components here (RSSAggregator & AtomAggregator). +2. AggregatorImpl directly implements the Tuscany Atom Collection interface. It is a component + that provides an Atom feed to respond (see tuscany/modules/binding-atom-abdera) +3. The AggregatorImpl component is not explicitly configured using nested element nor its + implementation class is annotated with @Service annotation. Instead, the Tuscany Atom Collection interface + defines its services using @Remotable annotation. + +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 + + +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-20080910/samples/feed-aggregator/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/build.xml new file mode 100644 index 0000000000..0ab6fed7fc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/feed-aggregator.png b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/feed-aggregator.png new file mode 100644 index 0000000000..c8fea8a7b8 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/feed-aggregator.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/feed-aggregator.svg b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/feed-aggregator.svg new file mode 100644 index 0000000000..72fe6a00ac --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/feed-aggregator.svg @@ -0,0 +1,364 @@ + + + + + + + + + + + + + image/svg+xml + + + + + + + + FeedAggregator + Sort + + newFirst = true + + RssAggregator + + + + + AtomAggregator + + + Rss Sample + Atom Sample + + + + + + + + + + Engadget + BBC + Oreilly + Apache + + + RSS Atom + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/pom.xml new file mode 100644 index 0000000000..5e869ba608 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/pom.xml @@ -0,0 +1,84 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../pom.xml + + sample-feed-aggregator + Apache Tuscany SCA Atom+RSS Feed Aggregator Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-rss-rome + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java new file mode 100644 index 0000000000..70e05b3bb3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java @@ -0,0 +1,188 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package feed; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.apache.abdera.Abdera; +import org.apache.abdera.factory.Factory; +import org.apache.abdera.model.Document; +import org.apache.abdera.model.Entry; +import org.apache.abdera.model.Feed; +import org.apache.abdera.model.Person; +import org.apache.abdera.parser.Parser; +import org.apache.tuscany.sca.binding.atom.collection.Collection; +import org.apache.tuscany.sca.binding.atom.collection.NotFoundException; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; + +import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.io.SyndFeedOutput; + +/** + * Implementation of an SCA component that aggregates several + * Atom and RSS feeds. + * + * @version $Rev$ $Date$ + */ +public class AggregatorImpl implements org.apache.tuscany.sca.binding.atom.collection.Collection { + + @Reference(required = false) + public Collection atomFeed1; + @Reference(required = false) + public Collection atomFeed2; + + @Reference(required = false) + public org.apache.tuscany.sca.binding.rss.collection.Collection rssFeed1; + @Reference(required = false) + public org.apache.tuscany.sca.binding.rss.collection.Collection rssFeed2; + + @Reference(required = false) + public Sort sort; + + @Property + public String feedTitle = "Aggregated Feed"; + @Property + public String feedDescription = "Anonymous Aggregated Feed"; + @Property + public String feedAuthor = "anonymous"; + + public Feed getFeed() { + + // Create a new Feed + Factory factory = Abdera.getNewFactory(); + Feed feed = factory.newFeed(); + feed.setTitle(feedTitle); + feed.setSubtitle(feedDescription); + Person author = factory.newAuthor(); + author.setName(feedAuthor); + feed.addAuthor(author); + feed.addLink("http://tuscany.apache.org/", "alternate"); + + // Aggregate entries from atomFeed1, atomFeed2, rssFeed1 and rssFeed2 + List entries = new ArrayList(); + if (atomFeed1 != null) { + try { + entries.addAll(atomFeed1.getFeed().getEntries()); + } catch (Exception e) {} + } + if (atomFeed2 != null) { + try { + entries.addAll(atomFeed2.getFeed().getEntries()); + } catch (Exception e) {} + } + if (rssFeed1 != null) { + try { + entries.addAll(atomFeed(rssFeed1.getFeed()).getEntries()); + } catch (Exception e) {} + } + if (rssFeed2 != null) { + try { + entries.addAll(atomFeed(rssFeed2.getFeed()).getEntries()); + } catch (Exception e) {} + } + + // Sort entries by updated date + if (sort != null) { + entries = sort.sort(entries); + } + + // Add the entries to the new feed + // Also synthesize a feed id and updated field base on entries + Date feedUpdated = new Date( 0 ); + for (Entry entry: entries) { + Date entryUpdated = entry.getUpdated(); + if (( entryUpdated != null ) && ( entryUpdated.compareTo( feedUpdated ) > 0 )) { + feedUpdated = entryUpdated; + } + feed.addEntry(entry); + } + feed.setUpdated( feedUpdated ); + // Note that feed id should be permanent, immutable, and unique + // in order to support proper ETag creation. + // Tough to do when the feed is regenerated with each get. + feed.setId( "http://tuscany.apache.org/feed", true ); + + return feed; + } + + public Feed query(String queryString) { + Factory factory = Abdera.getNewFactory(); + Feed feed = factory.newFeed(); + feed.setTitle(feedTitle); + feed.setSubtitle(feedDescription); + Person author = factory.newAuthor(); + author.setName(feedAuthor); + feed.addAuthor(author); + feed.addLink("http://tuscany.apache.org", "alternate"); + + Feed allFeed = getFeed(); + if (queryString.startsWith("title=")) { + String title = queryString.substring(6); + + for (Entry entry: allFeed.getEntries()) { + if (entry.getTitle().contains(title)) { + feed.addEntry(entry); + } + } + } + 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 void put(String id, Entry entry) throws NotFoundException { + } + + /** + * Convert a ROME feed to an Abdera feed. + * + * @param romeFeed + * @return + */ + private static Feed atomFeed(SyndFeed syndFeed) { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + + syndFeed.setFeedType("atom_1.0"); + SyndFeedOutput syndOutput = new SyndFeedOutput(); + try { + syndOutput.output(syndFeed, new OutputStreamWriter(bos)); + } catch (Exception e) { + throw new RuntimeException(e); + } + Parser parser = Abdera.getNewParser(); + Document document = parser.parse(new ByteArrayInputStream(bos.toByteArray())); + + return document.getRoot(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/java/feed/Sort.java b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/java/feed/Sort.java new file mode 100644 index 0000000000..dec073c36b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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 org.apache.abdera.model.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-20080910/samples/feed-aggregator/src/main/java/feed/SortImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/java/feed/SortImpl.java new file mode 100644 index 0000000000..f7ead126a7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/java/feed/SortImpl.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 feed; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.Date; +import java.util.List; + +import org.apache.abdera.model.Entry; +import org.osoa.sca.annotations.Property; + +/** + * Implementation of a Feed Sort service component. + * + * @version $Rev$ $Date$ + */ +public class SortImpl implements Sort { + + @Property + public boolean newFirst = true; + + @SuppressWarnings("unchecked") + public List sort(List entries) { + Entry[] entriesArray = new Entry[entries.size()]; + entriesArray = (Entry[])entries.toArray(entriesArray); + Arrays.sort(entriesArray, new Comparator() { + public int compare(final Object xObj, final Object yObj) { + Date xDate = ((Entry)xObj).getUpdated(); + Date yDate = ((Entry)yObj).getUpdated(); + 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-20080910/samples/feed-aggregator/src/main/java/launch/LaunchFeedServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/java/launch/LaunchFeedServer.java new file mode 100644 index 0000000000..1c549f7cd2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/java/launch/LaunchFeedServer.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 launch; + +import java.io.IOException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class LaunchFeedServer { + 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(); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + + scaDomain.close(); + System.out.println("Sample Feed server stopped"); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/resources/FeedAggregator.composite b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/resources/FeedAggregator.composite new file mode 100644 index 0000000000..8a3a53b4d5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/main/resources/FeedAggregator.composite @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + RSS Aggregator Sample + + + + true + + + + + + + + + + + + Atom Aggregator Sample + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTest.java b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTest.java new file mode 100644 index 0000000000..9fdfe711be --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTest.java @@ -0,0 +1,332 @@ +package feed; + +import java.io.IOException; +import java.io.Reader; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import junit.framework.Assert; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import org.apache.abdera.Abdera; +import org.apache.abdera.i18n.iri.IRI; +import org.apache.abdera.factory.Factory; +import org.apache.abdera.model.Base; +import org.apache.abdera.model.Content; +import org.apache.abdera.model.Entry; +import org.apache.abdera.model.Feed; +import org.apache.abdera.model.Document; +import org.apache.abdera.model.Collection; +import org.apache.abdera.protocol.Response.ResponseType; +import org.apache.abdera.protocol.client.AbderaClient; +import org.apache.abdera.protocol.client.ClientResponse; +import org.apache.abdera.protocol.client.RequestOptions; +import org.apache.abdera.util.EntityTag; +import org.apache.abdera.writer.Writer; +import org.apache.abdera.writer.WriterFactory; +import org.apache.abdera.parser.Parser; + +/** + * Tests use of server provided feed entity tags for Atom binding in Tuscany. + * Tests conditional gets (e.g. get if-none-match) or conditional posts (post if-match) + * using entity tags and last modified entries in headers. + * Uses the SCA provided Provider composite to act as a server. + * Uses the Abdera provided Client to act as a client. + */ +public class FeedAggregatorTest { + public final static String providerURI = "http://localhost:8083/atomAggregator"; + protected static SCADomain scaProviderDomain; + protected static Abdera abdera; + protected static AbderaClient client; + protected static Parser abderaParser; + protected static String eTag; + protected static Date lastModified; + protected static long contentLength; + protected static int numberEntries; + protected static final SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println(">>>FeedAggregatorTest.init"); + scaProviderDomain = SCADomain.newInstance("FeedAggregator.composite"); + abdera = new Abdera(); + client = new AbderaClient(abdera); + abderaParser = Abdera.getNewParser(); + } catch ( Throwable e ) { + System.out.println( e ); + e.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + System.out.println(">>>FeedAggregatorTest.destroy"); + scaProviderDomain.close(); + } + + @Test + public void testPrelim() throws Exception { + Assert.assertNotNull(scaProviderDomain); + Assert.assertNotNull( client ); + } + + @Test + public void testFeedBasics() throws Exception { + System.out.println(">>>FeedAggregatorTest.testFeedBasics"); + RequestOptions opts = new RequestOptions(); + // Normal feed request + ClientResponse res = client.get(providerURI, opts); + Assert.assertNotNull(res); + try { + // Asser feed provided since no predicates + Assert.assertEquals(200, res.getStatus()); + Assert.assertEquals(ResponseType.SUCCESS, res.getType()); + // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", " ", res ); + + // Perform other tests on feed. + contentLength = getContentLength( res ); + System.out.println( "FeedAggregatorTest.testFeedBasics full contentLength=" + contentLength ); + + Document doc = res.getDocument(); + Assert.assertNotNull( doc ); + Feed feed = doc.getRoot(); + Assert.assertNotNull( feed ); + + // printFeed( "Feed values", " ", feed ); + // RFC 4287 requires non-null id, title, updated elements + Assert.assertNotNull( feed.getId() ); + Assert.assertNotNull( feed.getTitle() ); + Assert.assertNotNull( feed.getUpdated() ); + + eTag = res.getHeader("ETag"); + Assert.assertNotNull( eTag ); + lastModified = res.getLastModified(); + Assert.assertNotNull( lastModified ); + + numberEntries = getEntryCount( feed ); + System.out.println( "FeedAggregatorTest.testFeedBasics number entries=" + numberEntries ); + + // printFeed( "Aggregated Feed Contents:", " ", feed ); + // System.out.println( "FeedAggregatorTest.testFeedBasics feed=" + feed ); + // printResponseHeaders( "Aggregated Feed response headers:", " ", res ); + // System.out.println("Aggregated Feed response body:"); + // prettyPrint(abdera, res.getDocument()); + // printEntryUpdates( "Aggregated Feed feed updates", " ", feed ); + } finally { + res.release(); + } + } + + @Test + public void testUnmodifiedGetIfModified() throws Exception { + System.out.println(">>>FeedAggregatorTest.testFeedUnmodifiedGetIfModified"); + // Feed request with predicates + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml"; + opts.setContentType(contentType); + opts.setHeader( "If-Modified-Since", dateFormat.format( new Date( 0 ) )); + + ClientResponse res = client.get(providerURI, opts); + Assert.assertNotNull(res); + try { + // Should return 200 - Feed provided since feed is changed. + Assert.assertEquals(200, res.getStatus()); + Assert.assertEquals(ResponseType.SUCCESS, res.getType()); + + String thisETag = res.getHeader("ETag"); + Assert.assertNotNull( thisETag ); + Date thisLastModified = res.getLastModified(); + Assert.assertNotNull( thisLastModified ); + + // Entry count and body size should be equal to basic request + long thisContentLength = getContentLength( res ); + + Document doc = res.getDocument(); + Assert.assertNotNull( doc ); + Feed feed = doc.getRoot(); + Assert.assertNotNull( feed ); + int thisNumberEntries = getEntryCount( feed ); + // System.out.println( "FeedAggregatorTest.UnmodifiedGetIfModified number entries=" + numberEntries + ", this number entries=" + thisNumberEntries ) ; + } finally { + res.release(); + } + } + + @Test + public void testUnmodifiedGetIfUnModified() throws Exception { + System.out.println(">>>FeedAggregatorTest.testFeedUnmodifiedGetIfUnModified"); + // Feed request with predicates + RequestOptions opts = new RequestOptions(); + final String contentType = "application/atom+xml"; + opts.setContentType(contentType); + opts.setHeader( "If-Unmodified-Since", dateFormat.format( new Date( 0 ) )); + + ClientResponse res = client.get(providerURI, opts); + Assert.assertNotNull(res); + try { + // Should return 304 - Feed not provided since feed is modified since. + Assert.assertEquals(304, res.getStatus()); + + // Entry count and body size should be equal to basic request + long thisContentLength = getContentLength( res ); + System.out.println( "FeedAggregatorTest.UnModifiedGetIfUnModified saved " + (contentLength - thisContentLength) + " bytes of network traffic due to caching."); + } finally { + res.release(); + } + } + + /** Print feed vital fields. */ + public static void printFeed( String title, String indent, Feed feed ) { + if ( feed == null ) { + System.out.println( title + " feed is null"); + return; + } + + System.out.println( title ); + System.out.println( indent + "id=" + feed.getId() ); + System.out.println( indent + "title=" + feed.getTitle() ); + System.out.println( indent + "updated=" + feed.getUpdated() ); + System.out.println( indent + "author=" + feed.getAuthor() ); + System.out.println( indent + "self link=" + feed.getSelfLink() ); + Collection collection = feed.getCollection(); + if ( collection == null ) { + System.out.println( indent + "collection=null" ); + } else { + System.out.println( indent + "collection=" + collection ); + } + } + + /* Print headers of request. */ + public static void printRequestHeaders( String title, String indent, RequestOptions request ) { + System.out.println( title ); + if ( request == null ) { + System.out.println( indent + " request is null"); + return; + } + String [] headerNames = request.getHeaderNames(); + for ( String headerName: headerNames) { + String header = request.getHeader(headerName); + System.out.println( indent + " header name,value=" + headerName + "," + header ); + } + } + + /* Print headers of response. */ + public static void printResponseHeaders( String title, String indent, ClientResponse response ) { + System.out.println( title ); + if ( response == null ) { + System.out.println( indent + " response is null"); + return; + } + String [] headerNames = response.getHeaderNames(); + for ( String headerName: headerNames) { + String header = response.getHeader(headerName); + System.out.println( indent + " header name,value=" + headerName + "," + header ); + } + + } + + /** Pretty print the document body. */ + public static void prettyPrint(Abdera abdera, Base doc) throws IOException { + WriterFactory factory = abdera.getWriterFactory(); + Writer writer = factory.getWriter("prettyxml"); + writer.writeTo(doc, System.out); + System.out.println(); + } + + /** Print the updated elements of the feed entries. */ + public static void printEntryUpdates( String title, String indent, Feed feed ) { + if ( feed == null ) { + System.out.println( title + " feed is null"); + return; + } + + System.out.println( title ); + List entries = feed.getEntries(); + if ( entries == null ) { + System.out.println( indent + " null entries"); + } + System.out.println( indent + "entries size=" + entries.size()); + + int i = 0; + for ( Entry entry: entries ) { + String entryTitle = entry.getTitle(); + if (( entryTitle != null ) && ( entryTitle.length() > 20 )) + entryTitle = entryTitle.substring( 0, 20 ); + // System.out.println( indent + i++ + ": title=\"" + entryTitle + + // "\", updated=" + entry.getUpdated() + ", published=" + entry.getPublished() ); + System.out.println( indent + i++ + ": title=\"" + entryTitle + + "\", updated=" + entry.getUpdated() ); + } + } + + /** Get the length of the response body content. */ + public static long getContentLength( ClientResponse response ) { + // getContentLenght returns -1 + // contentLength = response.getContentLength(); + try { + Reader reader = response.getReader(); + long actualSkip = reader.skip( Long.MAX_VALUE ); + return actualSkip; + } catch ( IOException e ) { + } + return -1L; + } + + /** Get a count of entries in the feed. */ + public static int getEntryCount( Feed feed ) { + if ( feed == null ) { + return 0; + } + + List entries = feed.getEntries(); + if ( entries == null ) { + return 0; + } + return entries.size(); + } + + /** Given a feed, determine the median point of the entries. + * Use the updated field of the entries to determine median. + * @param feed + * @return + */ + public static Date getUpdatedMedian( Feed feed ) { + Date sentinal = null; + if ( feed == null ) { + return sentinal; + } + + List entries = feed.getEntries(); + if ( entries == null ) { + return sentinal; + } + int size = entries.size(); + if( size == 0 ) { + return sentinal; + } + // System.out.println( "getUpdatedMedian entries size=" + entries.size()); + ArrayList updates = new ArrayList( size ); + + for ( Entry entry: entries ) { + Date entryUpdated = entry.getUpdated(); + if ( entryUpdated == null ) { + entryUpdated = new Date( 0 ); + } + updates.add( entryUpdated ); + } + Collections.sort( updates ); + // System.out.println( "getUpdatedMedian entry min update=" + updates.get( 0 )); + // System.out.println( "getUpdatedMedian entry max update=" + updates.get( size - 1 )); + Date median = updates.get( size/2 ); + // System.out.println( "getUpdatedMedian entry max median=" + median ); + return median; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/README new file mode 100644 index 0000000000..5c669f5da5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/README @@ -0,0 +1,151 @@ +Hello World BPEL Webservices Sample +====================================== +This sample demonstrates an SCA service implemented by a BPEL process, made available 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. + +If you just want to run it to see what happens open a command prompt, navigate +to this sample directory, and do + +ant compile run + +OR if you don't have ant, on Windows do + +mkdir target\classes +mkdir target\wsdl2java-source +java -cp ..\..\lib\tuscany-sca-manifest.jar org.apache.tuscany.sdo.generate.XSD2JavaGenerator -targetDirectory target/wsdl2java-source -prefix HelloWorld -noContainment -noUnsettable src/main/resources/helloworld.wsdl +java -cp ..\..\lib\tuscany-sca-manifest.jar org.apache.tuscany.tools.wsdl2java.generate.WSDL2JavaGenerator -targetDirectory target/wsdl2java-source src/main/resources/helloworld.wsdl +unzip ..\..\lib\ode-dao-jpa-ojpa-derby-1.1.zip -d target\database +javac -d target\classes -cp target\classes;..\..\lib\tuscany-sca-manifest.jar -sourcepath src\main\java;target\wsdl2java-source -target 1.5 -g -source 1.5 src\main\java\helloworld\BPELClient.java +copy src\main\resources\* target\classes +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\classes;target\database helloworld.BPELClient + +and on *nix do + +mkdir target/classes +mkdir target/wsdl2java-source +java -cp ../../lib/tuscany-sca-manifest.jar org.apache.tuscany.sdo.generate.XSD2JavaGenerator -targetDirectory target/wsdl2java-source -prefix HelloWorld -noContainment -noUnsettable src/main/resources/helloworld.wsdl +java -cp ../../lib/tuscany-sca-manifest.jar org.apache.tuscany.tools.wsdl2java.generate.WSDL2JavaGenerator -targetDirectory target/wsdl2java-source src/main/resources/helloworld.wsdl +unzip ../../lib/ode-dao-jpa-ojpa-derby-1.1.zip -d target/database +javac -d target/classes -cp target/classes;../../lib/tuscany-sca-manifest.jar -sourcepath src/main/java;target/wsdl2java-source -target 1.5 -g -source 1.5 src/main/java/helloworld/BPELClient.java +cp src/main/resources/* target/classes +java -cp ../../lib/tuscany-sca-manifest.jar:target/classes:target/database helloworld.BPELClient + +The sample will start an embedded BPEL engine, deploy a process and invoke it. + +Sample Overview +--------------- +The sample provides a single component that is wired to a service with a +web service binding. + +helloworld-bpel/ + src/ + main/ + java/ + helloworld/ + BPELClient.java - client application for + BEPELHelloWorldComponent + + resources/ + deploy.xml - ODE deployment descriptor + helloworld.bpel - helloworld bpel process + helloworld.componentType - helloworld bpel service description + helloworld.composite - the SCA assembly for this sample + helloworld.wsdl - the service description that describes + the bpel process + log4j.properties - logging configuration + + test/ + java/ + helloworld/ + BPELHelloWorldTestCase.java - JUnit test case + helloworld-bpel.png - a pictorial representation of the + sample .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- + +With the binary distribution the sample can be built and run using Ant as +follows + +cd helloworld-bpel +ant compile +ant run + + +You should see the following output from the run target. + +run: + [java] Starting BPELHelloWorldComponent + [java] >>> Deploying : D:\temp\SCA1.1-RC1\tuscany-sca-1.1-incubating\samples\helloworld-bpel\target\classes + [java] ::arg:::::: + [java] Hello + [java] ::message:: + [java] Hello + [java] Status: RESPONSE + [java] Response: + [java] Hello World + [java] Hello World + [java] Stopping BPELHelloWorldComponent + [java] Stopped !!! + +BUILD SUCCESSFUL +Total time: 36 seconds + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. When using Maven, a simple test is present that exercise +the same logic as the client to invoke the BPEl process. + +cd helloworld-bpel +mvn + +You should see the following output from the test phase. + +- + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running helloworld.BPELHelloWorldTestCase +Starting BPELHelloWorldComponent +>>> Deploying : D:\dev\Opensource\Apache\Tuscany\source\java-sca-1.1\samples\helloworld-bpel\target\classes +::arg:::::: +Hello +::message:: +Hello +Status: RESPONSE +Response: +Hello World +Stopping BPELHelloWorldComponent +Stopped !!! +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 18.656 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] [jar:jar] +[INFO] Building jar: D:\dev\Opensource\Apache\Tuscany\source\java-sca-1.1\samples\helloworld-bpel\target\sample-helloworld-bpel.jar +[INFO] [install:install] +[INFO] Installing D:\dev\Opensource\Apache\Tuscany\source\java-sca-1.1\samples\helloworld-bpel\target\sample-helloworld-bpel.jar to C:\Documents and Settings\lresend +e\.m2\repository\org\apache\tuscany\sca\sample-helloworld-bpel\1.1-incubating-SNAPSHOT\sample-helloworld-bpel-1.1-incubating-SNAPSHOT.jar +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESSFUL +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 53 seconds +[INFO] Finished at: Sun Jan 13 09:54:39 PST 2008 +[INFO] Final Memory: 24M/43M +[INFO] ------------------------------------------------------------------------ + + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/build.xml new file mode 100644 index 0000000000..c8917007f1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/build.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/helloworld-bpel.png b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/helloworld-bpel.png new file mode 100644 index 0000000000..5f53a3c5d1 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/helloworld-bpel.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/helloworld-bpel.svg b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/helloworld-bpel.svg new file mode 100644 index 0000000000..5a98f1a07c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/helloworld-bpel.svg @@ -0,0 +1,179 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldws + + HelloWorldServiceComponent + + HelloWorldWebService + + implementation.bpel helloworld.bpel + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/pom.xml new file mode 100644 index 0000000000..c20ade8d82 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/pom.xml @@ -0,0 +1,205 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-bpel-ws + Apache Tuscany SCA HelloWorld BPEL as Webservice Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-bpel-ode + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.1-incubating + + + + xerces + xercesImpl + 2.8.1 + + + + junit + junit + 4.2 + test + + + + org.apache.tuscany.sca + tuscany-wsdl2java + 1.4-SNAPSHOT + + + + org.apache.tuscany.sdo + tuscany-sdo-tools + 1.1-incubating + + + + org.codehaus.woodstox + wstx-asl + 3.2.1 + runtime + + + + com.sun.xml.bind + jaxb-impl + 2.1.7 + compile + + + javax.xml.stream + stax-api + + + + + + + + ${artifactId} + + + org.apache.maven.plugins + maven-surefire-plugin + + 2.3.1 + + false + false + true + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + test-compile + + unpack + + + + + org.apache.ode + ode-dao-jpa-ojpa-derby + 1.1 + zip + true + ${project.build.directory}/test-classes/ + + + + + + + + org.apache.tuscany.sdo + tuscany-sdo-plugin + 1.1-incubating + + + generate-bpel-helloworld + generate-sources + + ${basedir}/src/main/resources/helloworld.wsdl + ${basedir}/target/wsdl2java-source + HelloWorld + true + true + true + + + generate + + + + + + org.apache.tuscany.sca + tuscany-maven-wsdl2java + 1.4-SNAPSHOT + + + + ${basedir}/src/main/resources/helloworld.wsdl + + + generate + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/java/helloworld/BPELClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/java/helloworld/BPELClient.java new file mode 100644 index 0000000000..971a5373e9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/java/helloworld/BPELClient.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 helloworld; + +import org.apache.tuscany.implementation.bpel.example.helloworld.HelloPortType; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Simple BPEL sample application invoking a helloworld + * + * @version $Rev: 613905 $ $Date: 2008-01-21 14:41:15 +0000 (Mon, 21 Jan 2008) $ + */ +public class BPELClient { + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("helloworld.composite"); + HelloPortType bpelService = scaDomain.getService(HelloPortType.class, "BPELHelloWorldComponent"); + + String result = bpelService.hello("Hello"); + System.out.println(result); + + scaDomain.close(); + + System.exit(0); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/deploy.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/deploy.xml new file mode 100644 index 0000000000..d9d4363832 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/deploy.xml @@ -0,0 +1,31 @@ + + + + + + true + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.bpel b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.bpel new file mode 100644 index 0000000000..a88aa7960c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.bpel @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + concat($tmpVar,' World') + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.componentType b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.componentType new file mode 100644 index 0000000000..70273245d7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.componentType @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.composite new file mode 100644 index 0000000000..97262109e6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.wsdl b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.wsdl new file mode 100644 index 0000000000..1cb338b283 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/helloworld.wsdl @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/log4j.properties b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/log4j.properties new file mode 100644 index 0000000000..c1bc0a0b81 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/main/resources/log4j.properties @@ -0,0 +1,35 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Set root logger level to WARN and its only appender to CONSOLE +log4j.rootLogger=OFF, CONSOLE + +# log4j properties to work with commandline tools. +log4j.category.org.mortbay=OFF +log4j.category.org.hibernate.type=OFF +log4j.category.org.objectweb=OFF +log4j.category.org.apache.ode.sql=OFF +log4j.category.org.apache.ode.axis2=OFF +log4j.category.org.apache.ode.bpel.engine=OFF +log4j.category.org.apache.ode.daohib.bpel.CorrelatorDaoImpl=OFF +log4j.category.org.apache.ode.bpel.epr=OFF +log4j.category.org.apache.openjpa.kernel=OFF + +# Console appender +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%p - %C{1}.%M(%L) | %m%n \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/test/java/helloworld/BPELHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/test/java/helloworld/BPELHelloWorldTestCase.java new file mode 100644 index 0000000000..6ad63f87d9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel-ws/src/test/java/helloworld/BPELHelloWorldTestCase.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 helloworld; + +import junit.framework.TestCase; + +import org.apache.tuscany.implementation.bpel.example.helloworld.HelloPortType; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Tests the BPEL service + * + * @version $Rev: 636807 $ $Date: 2008-03-13 17:32:45 +0000 (Thu, 13 Mar 2008) $ + */ +public class BPELHelloWorldTestCase extends TestCase { + + private SCADomain scaDomain; + HelloPortType bpelService = null; + + /** + * @throws java.lang.Exception + */ + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("helloworld.composite"); + bpelService = scaDomain.getService(HelloPortType.class, "BPELHelloWorldComponent"); + + } + + /** + * @throws java.lang.Exception + */ + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testInvoke() throws Exception { + String response = bpelService.hello("Hello"); + assertEquals("Hello World", response); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/README new file mode 100644 index 0000000000..bf5f500ef3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/README @@ -0,0 +1,151 @@ +Hello World BPEL Sample +====================================== +This sample demonstrates an SCA service implemented by a BPEL process. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +If you just want to run it to see what happens open a command prompt, navigate +to this sample directory, and do + +ant compile run + +OR if you don't have ant, on Windows do + +mkdir target\classes +mkdir target\wsdl2java-source +java -cp ..\..\lib\tuscany-sca-manifest.jar org.apache.tuscany.sdo.generate.XSD2JavaGenerator -targetDirectory target/wsdl2java-source -prefix HelloWorld -noContainment -noUnsettable src/main/resources/helloworld.wsdl +java -cp ..\..\lib\tuscany-sca-manifest.jar org.apache.tuscany.tools.wsdl2java.generate.WSDL2JavaGenerator -targetDirectory target/wsdl2java-source src/main/resources/helloworld.wsdl +unzip ..\..\lib\ode-dao-jpa-ojpa-derby-1.1.zip -d target\database +javac -d target\classes -cp target\classes;..\..\lib\tuscany-sca-manifest.jar -sourcepath src\main\java;target\wsdl2java-source -target 1.5 -g -source 1.5 src\main\java\helloworld\BPELClient.java +copy src\main\resources\* target\classes +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\classes;target\database helloworld.BPELClient + +and on *nix do + +mkdir target/classes +mkdir target/wsdl2java-source +java -cp ../../lib/tuscany-sca-manifest.jar org.apache.tuscany.sdo.generate.XSD2JavaGenerator -targetDirectory target/wsdl2java-source -prefix HelloWorld -noContainment -noUnsettable src/main/resources/helloworld.wsdl +java -cp ../../lib/tuscany-sca-manifest.jar org.apache.tuscany.tools.wsdl2java.generate.WSDL2JavaGenerator -targetDirectory target/wsdl2java-source src/main/resources/helloworld.wsdl +unzip ../../lib/ode-dao-jpa-ojpa-derby-1.1.zip -d target/database +javac -d target/classes -cp target/classes;../../lib/tuscany-sca-manifest.jar -sourcepath src/main/java;target/wsdl2java-source -target 1.5 -g -source 1.5 src/main/java/helloworld/BPELClient.java +cp src/main/resources/* target/classes +java -cp ../../lib/tuscany-sca-manifest.jar:target/classes:target/database helloworld.BPELClient + +The sample will start an embedded BPEL engine, deploy a process and invoke it. + +Sample Overview +--------------- +The sample provides a single component that is wired to a service with a +web service binding. + +helloworld-bpel/ + src/ + main/ + java/ + helloworld/ + BPELClient.java - client application for + BEPELHelloWorldComponent + + resources/ + deploy.xml - ODE deployment descriptor + helloworld.bpel - helloworld bpel process + helloworld.componentType - helloworld bpel service description + helloworld.composite - the SCA assembly for this sample + helloworld.wsdl - the service description that describes + the bpel process + log4j.properties - logging configuration + + test/ + java/ + helloworld/ + BPELHelloWorldTestCase.java - JUnit test case + helloworld-bpel.png - a pictorial representation of the + sample .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- + +With the binary distribution the sample can be built and run using Ant as +follows + +cd helloworld-bpel +ant compile +ant run + + +You should see the following output from the run target. + +run: + [java] Starting BPELHelloWorldComponent + [java] >>> Deploying : D:\temp\SCA1.1-RC1\tuscany-sca-1.1-incubating\samples\helloworld-bpel\target\classes + [java] ::arg:::::: + [java] Hello + [java] ::message:: + [java] Hello + [java] Status: RESPONSE + [java] Response: + [java] Hello World + [java] Hello World + [java] Stopping BPELHelloWorldComponent + [java] Stopped !!! + +BUILD SUCCESSFUL +Total time: 36 seconds + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. When using Maven, a simple test is present that exercise +the same logic as the client to invoke the BPEl process. + +cd helloworld-bpel +mvn + +You should see the following output from the test phase. + +- + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running helloworld.BPELHelloWorldTestCase +Starting BPELHelloWorldComponent +>>> Deploying : D:\dev\Opensource\Apache\Tuscany\source\java-sca-1.1\samples\helloworld-bpel\target\classes +::arg:::::: +Hello +::message:: +Hello +Status: RESPONSE +Response: +Hello World +Stopping BPELHelloWorldComponent +Stopped !!! +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 18.656 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] [jar:jar] +[INFO] Building jar: D:\dev\Opensource\Apache\Tuscany\source\java-sca-1.1\samples\helloworld-bpel\target\sample-helloworld-bpel.jar +[INFO] [install:install] +[INFO] Installing D:\dev\Opensource\Apache\Tuscany\source\java-sca-1.1\samples\helloworld-bpel\target\sample-helloworld-bpel.jar to C:\Documents and Settings\lresend +e\.m2\repository\org\apache\tuscany\sca\sample-helloworld-bpel\1.1-incubating-SNAPSHOT\sample-helloworld-bpel-1.1-incubating-SNAPSHOT.jar +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESSFUL +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 53 seconds +[INFO] Finished at: Sun Jan 13 09:54:39 PST 2008 +[INFO] Final Memory: 24M/43M +[INFO] ------------------------------------------------------------------------ + + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/build.xml new file mode 100644 index 0000000000..890a6427b8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/build.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/helloworld-bpel.png b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/helloworld-bpel.png new file mode 100644 index 0000000000..5f53a3c5d1 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/helloworld-bpel.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/helloworld-bpel.svg b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/helloworld-bpel.svg new file mode 100644 index 0000000000..5a98f1a07c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/helloworld-bpel.svg @@ -0,0 +1,179 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldws + + HelloWorldServiceComponent + + HelloWorldWebService + + implementation.bpel helloworld.bpel + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/pom.xml new file mode 100644 index 0000000000..e606edb2e5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/pom.xml @@ -0,0 +1,198 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-bpel + Apache Tuscany SCA HelloWorld BPEL Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-bpel-ode + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.1.1 + + + + xerces + xercesImpl + 2.8.1 + + + + junit + junit + 4.2 + test + + + + org.apache.tuscany.sca + tuscany-wsdl2java + 1.4-SNAPSHOT + + + + org.apache.tuscany.sdo + tuscany-sdo-tools + 1.1.1 + + + + org.codehaus.woodstox + wstx-asl + 3.2.1 + runtime + + + + javax.xml.bind + jaxb-api + 2.1 + compile + + + javax.xml.stream + stax-api + + + + + + com.sun.xml.bind + jaxb-impl + 2.1.7 + runtime + + + + + + ${artifactId} + + + org.apache.maven.plugins + maven-surefire-plugin + + 2.3.1 + + false + false + true + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + test-compile + + unpack + + + + + org.apache.ode + ode-dao-jpa-ojpa-derby + 1.1 + zip + true + ${project.build.directory}/test-classes/ + + + + + + + + org.apache.tuscany.sdo + tuscany-sdo-plugin + 1.1.1 + + + generate-bpel-helloworld + generate-sources + + ${basedir}/src/main/resources/helloworld.wsdl + ${basedir}/target/wsdl2java-source + HelloWorld + true + true + true + + + generate + + + + + + org.apache.tuscany.sca + tuscany-maven-wsdl2java + 1.4-SNAPSHOT + + + + ${basedir}/src/main/resources/helloworld.wsdl + + + generate + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.java new file mode 100644 index 0000000000..1826c885c4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.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 helloworld; + +import org.apache.tuscany.implementation.bpel.example.helloworld.HelloPortType; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Simple BPEL sample application invoking a helloworld + * + * @version $Rev$ $Date$ + */ +public class BPELClient { + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("helloworld.composite"); + HelloPortType bpelService = scaDomain.getService(HelloPortType.class, "BPELHelloWorldComponent"); + + String result = bpelService.hello("Hello"); + System.out.println(result); + + scaDomain.close(); + + System.exit(0); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/deploy.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/deploy.xml new file mode 100644 index 0000000000..9bd95b2c58 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/deploy.xml @@ -0,0 +1,31 @@ + + + + + + true + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.bpel b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.bpel new file mode 100644 index 0000000000..a88aa7960c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.bpel @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + concat($tmpVar,' World') + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.componentType b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.componentType new file mode 100644 index 0000000000..2b360111cb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.componentType @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.composite new file mode 100644 index 0000000000..b4623b5c2d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.wsdl b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.wsdl new file mode 100644 index 0000000000..46cf381577 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/helloworld.wsdl @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/log4j.properties b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/log4j.properties new file mode 100644 index 0000000000..8649a71550 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/main/resources/log4j.properties @@ -0,0 +1,35 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Set root logger level to WARN and its only appender to CONSOLE +log4j.rootLogger=OFF, CONSOLE + +# log4j properties to work with commandline tools. +log4j.category.org.mortbay=OFF +log4j.category.org.hibernate.type=OFF +log4j.category.org.objectweb=OFF +log4j.category.org.apache.ode.sql=OFF +log4j.category.org.apache.ode.axis2=OFF +log4j.category.org.apache.ode.bpel.engine=OFF +log4j.category.org.apache.ode.daohib.bpel.CorrelatorDaoImpl=OFF +log4j.category.org.apache.ode.bpel.epr=OFF +log4j.category.org.apache.openjpa.kernel=OFF + +# Console appender +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%p - %C{1}.%M(%L) | %m%n \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java new file mode 100644 index 0000000000..1caaa78878 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.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 helloworld; + +import junit.framework.TestCase; + +import org.apache.tuscany.implementation.bpel.example.helloworld.HelloPortType; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Tests the BPEL service + * + * @version $Rev$ $Date$ + */ +public class BPELHelloWorldTestCase extends TestCase { + + private SCADomain scaDomain; + HelloPortType bpelService = null; + + /** + * @throws java.lang.Exception + */ + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("helloworld.composite"); + bpelService = scaDomain.getService(HelloPortType.class, "BPELHelloWorldComponent"); + + } + + /** + * @throws java.lang.Exception + */ + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testInvoke() throws Exception { + String response = bpelService.hello("Hello"); + assertEquals("Hello World", response); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/README new file mode 100644 index 0000000000..0ea891b07f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/README @@ -0,0 +1,28 @@ +Distributed Helloworld Sample +============================= + +This sample demonstrates a distributed SCA domain using the JMS implementation of binding.sca which +automatically discovers available nodes and the services they contain. + +In this sample there are two nodes in the domain, a standalone node containing a Helloworld component, +and a webapp using a JSP with which invokes the Helloworld service in the domain. + +To run the sample: + +- Build the two sample modules with mvn or Ant. +- Deploy the helloworld-webapp war to Tomcat. +- Start the standalone node by: + in the helloworld-node folder do "mvn dependency:copy-dependencies" then: + java -Djava.ext.dirs=target\dependency -cp target\sample-helloworld-node.jar sample.HelloworldNode +- On a web browser go to: + http://localhost:8080/sample-helloworld-webapp + +You should see "Hello world" returned on the web page and the node console should show "HelloworldImpl.sayHello: world" + +How it works: + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/README new file mode 100644 index 0000000000..0ea891b07f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/README @@ -0,0 +1,28 @@ +Distributed Helloworld Sample +============================= + +This sample demonstrates a distributed SCA domain using the JMS implementation of binding.sca which +automatically discovers available nodes and the services they contain. + +In this sample there are two nodes in the domain, a standalone node containing a Helloworld component, +and a webapp using a JSP with which invokes the Helloworld service in the domain. + +To run the sample: + +- Build the two sample modules with mvn or Ant. +- Deploy the helloworld-webapp war to Tomcat. +- Start the standalone node by: + in the helloworld-node folder do "mvn dependency:copy-dependencies" then: + java -Djava.ext.dirs=target\dependency -cp target\sample-helloworld-node.jar sample.HelloworldNode +- On a web browser go to: + http://localhost:8080/sample-helloworld-webapp + +You should see "Hello world" returned on the web page and the node console should show "HelloworldImpl.sayHello: world" + +How it works: + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/pom.xml new file mode 100644 index 0000000000..941cb2b4ed --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/pom.xml @@ -0,0 +1,71 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-node + Apache Tuscany SCA Helloworld Node Sample + + + + org.apache.tuscany.sca + tuscany-node-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-sca-jms + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/java/sample/Helloworld.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/java/sample/Helloworld.java new file mode 100644 index 0000000000..386426df73 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/java/sample/Helloworld.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package sample; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Helloworld { + + String sayHello(String name); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/java/sample/HelloworldImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/java/sample/HelloworldImpl.java new file mode 100644 index 0000000000..033b4088c8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/java/sample/HelloworldImpl.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package sample; + +public class HelloworldImpl implements Helloworld { + + public String sayHello(String name) { + System.out.println("HelloworldImpl.sayHello: " + name); + return "Hello " + name; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/java/sample/HelloworldNode.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/java/sample/HelloworldNode.java new file mode 100644 index 0000000000..3cd8fe547a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/java/sample/HelloworldNode.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package sample; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; + +/** + */ +public class HelloworldNode { + + public static void main(String[] args) throws Exception { + + SCANode node = SCANodeFactory.newInstance().createSCANodeFromClassLoader("Helloworld.composite", null); + node.start(); + + System.out.println("Hit enter to stop node..."); + System.in.read(); + + node.stop(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/resources/Helloworld.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/resources/Helloworld.composite new file mode 100644 index 0000000000..0f827390c8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-node/src/main/resources/Helloworld.composite @@ -0,0 +1,28 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/README new file mode 100644 index 0000000000..0ea891b07f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/README @@ -0,0 +1,28 @@ +Distributed Helloworld Sample +============================= + +This sample demonstrates a distributed SCA domain using the JMS implementation of binding.sca which +automatically discovers available nodes and the services they contain. + +In this sample there are two nodes in the domain, a standalone node containing a Helloworld component, +and a webapp using a JSP with which invokes the Helloworld service in the domain. + +To run the sample: + +- Build the two sample modules with mvn or Ant. +- Deploy the helloworld-webapp war to Tomcat. +- Start the standalone node by: + in the helloworld-node folder do "mvn dependency:copy-dependencies" then: + java -Djava.ext.dirs=target\dependency -cp target\sample-helloworld-node.jar sample.HelloworldNode +- On a web browser go to: + http://localhost:8080/sample-helloworld-webapp + +You should see "Hello world" returned on the web page and the node console should show "HelloworldImpl.sayHello: world" + +How it works: + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/build.xml new file mode 100644 index 0000000000..e08dd3027a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/build.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/pom.xml new file mode 100644 index 0000000000..1fc96d1623 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/pom.xml @@ -0,0 +1,72 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-webapp + war + Apache Tuscany SCA Distributed Helloworld WebApp Sample + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-web-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-sca-jms + 1.4-SNAPSHOT + runtime + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + generate + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/java/sample/Helloworld.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/java/sample/Helloworld.java new file mode 100644 index 0000000000..7dd39b82a4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/java/sample/Helloworld.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Helloworld { + + String sayHello(String name); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/webapp/WEB-INF/web.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/webapp/WEB-INF/web.composite new file mode 100644 index 0000000000..0e8de1be42 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/webapp/WEB-INF/web.composite @@ -0,0 +1,29 @@ + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..1eefec1c48 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + + + Apache Tuscany Distributed Helloworld Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + hello.jsp + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/webapp/hello.jsp b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/webapp/hello.jsp new file mode 100644 index 0000000000..873329cf7c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-distributed/helloworld-webapp/src/main/webapp/hello.jsp @@ -0,0 +1,36 @@ + +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib uri="http://www.osoa.org/sca/sca_jsp.tld" prefix="sca" %> + + + + + + +

Apache Tuscany Distributed Helloworld Sample

+ + Calling service.sayHello("world") returns: + +

+ + <%= service.sayHello("world") %> + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/README new file mode 100644 index 0000000000..38392a13b6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/README @@ -0,0 +1,104 @@ +Hello World Dojo RPC Sample +=========================== + +Note. This sample is currently not working correctly on WebSphere - see TUSCANY-1990 + +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-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-helloworld-dojo-webapp + +The port and hostname will of course vary depending on your local installation. + +See also the similar helloworld-jsonrpc-webapp 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-webapp/ + 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-webapp.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-webapp +ant package + +This should result in a war file (sample-helloworld-dojo-webapp.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-webapp + +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-webapp +mvn + +Again this should result in a war file (sample-helloworld-dojo-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-20080910/samples/helloworld-dojo-webapp/build-dojo.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/build-dojo.xml new file mode 100644 index 0000000000..534a1dacd9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/build-dojo.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/build.xml new file mode 100644 index 0000000000..95813af65a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/build.xml @@ -0,0 +1,70 @@ + + +]> + + + + &buildDependency; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/helloworld-jsonrpc.png b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/helloworld-jsonrpc.png new file mode 100644 index 0000000000..57f90aed01 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/helloworld-jsonrpc.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/helloworld-jsonrpc.svg b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/helloworld-jsonrpc.svg new file mode 100644 index 0000000000..d5c3bc5d3e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/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-20080910/samples/helloworld-dojo-webapp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/pom.xml new file mode 100644 index 0000000000..35d4abd6c7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/pom.xml @@ -0,0 +1,163 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-dojo-webapp + war + Apache Tuscany SCA HelloWorld DOJO Sample WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.4-SNAPSHOT + runtime + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + 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 + + + + + + + + + + + + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + true + + + generate + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/java/helloworldjsonrpc/HelloWorldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/java/helloworldjsonrpc/HelloWorldService.java new file mode 100644 index 0000000000..3d8ea24f04 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/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-20080910/samples/helloworld-dojo-webapp/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..e205f4da9b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworldjsonrpc; + +import java.util.Date; + +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 new Date() + ": [JSONRPC] Hello " + name; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/resources/jsonrpc.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/resources/jsonrpc.composite new file mode 100644 index 0000000000..e895ab455d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/resources/jsonrpc.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/webapp/HelloWorldJSONRPC.html b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/webapp/HelloWorldJSONRPC.html new file mode 100644 index 0000000000..4195f3288c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/webapp/HelloWorldJSONRPC.html @@ -0,0 +1,98 @@ + + + +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 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

+ +
+
None Yet.
+
+
Dojo Debug:
+
+ + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/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-20080910/samples/helloworld-dojo-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..70cd67890a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + + + Apache Tuscany DOJO HelloWorld Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + HelloWorldJSONRPC.html + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/webapp/style.css b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/src/main/webapp/style.css new file mode 100644 index 0000000000..1071583264 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-dojo-webapp/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-20080910/samples/helloworld-jms-webapp/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/README new file mode 100644 index 0000000000..9be2e0b0f6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/README @@ -0,0 +1,130 @@ +JMS HelloWorld Sample +===================== +This sample demonstrates a simple webapp containing a hello world style client +and service using the JMS binding for request-response style messaging. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +As this sample provides a web app there is a manual step where the WAR file +that contains the sample is copied to your web app container. If you just want +to give this sample a go deploy the WAR file (target/sample-helloworld-jms-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-helloworld-jms-webapp/ + +The port and hostname will of course vary depending on your local installation. + +Configuring the JMS resources +----------------------------- + +The sample requires JMS resources be manually configured in the server environment, these are: + +- a JMS connection factory named "ConnectionFactory" +- a JMS queue named "HelloWorldService" + +See the following for how to define these resources depending on the application server being used: + +Tuscany with embedded ActiveMQ broker +------------------------------------- + + +Apache Tomcat +------------- + +No configuration is necessary for Tomcat as the sample WAR includes everything pre-configured to run +an ActiveMQ embedded JMS broker and to configure the JMS resources in JNDI. + +The JNDI resources are configured in the META-INF/comtext.xml file, for more information on running +ActiveMQ in Tomcat see: http://activemq.apache.org/tomcat.html + + +Apache Geronimo +--------------- + +For Apache Geronimo 2.0.1 (2.0.2 fails to define JMS resources for me) + +Logon to the Geronimo Server Console (http://localhost:8080/console, uid system, pswd manager) + +In the Console Navigation on the left under Services click JMS Resources + +At the bottom of the JMS Resources panel click under Create a new JMS Resource Group click For ActiveMQ + +In Resource Group Name enter "MyRGN" and click next + +At JMS Resource Group click Add Connection Factory + +For JMS Factory Type choose javax.jms.ConnectionFactory and click Next + +In Connection Factory Name enter "ConnectionFactory" and click Next + +Click Add destination + +For JMS Destination Type choose javax.jms.Queue and click Next + +Enter "HelloWorldService" for both Message Destination Name and PhysicalName and click Next + +Click Deploy Now + +Thats it, you're done. + + +WebSphere +--------- + +To define the JMS resources in a new WebSphere Application Server 6.1 installation: + +1) First define a Service integration bus: + +Logon to the WebSphere Integrated Solutions Console (http://localhost:9060/ibm/console) + +On the Left hand menu expand Service integration, and click on Buses. + +In the Buses panel click on New + +Enter a name for the bus, eg MyBus, and click Next, and then click Finish and Save the changes. + +In the Buses panel click on MyBus + +Find the Topology secion and click on Bus members + +Click on Add, leave the defaults and click Next, Next, Next, Finish, and Save the changes. + +Restart WebSphere and when back up logon back on to the Integrated Solutions Console + +2) Now define the JMS rescources + +On the Left hand menu expand Resources, and JMS and click on Connection Facotories. + +In the Connection factories panel click New. + +Leave the Default messaging provider and click OK + +Enter "ConnectionFactory" in the Name and JNDI name and in the Bus name in the Connection pane choose MyBus and click OK + +On the Left hand menu in JMS click on Queues + +In the Queues panel click New, accept the defaults and click OK + +Enter "HelloWorldService" for the Name and JNDI name and in the Bus name in the Connection pane choose MyBus, +and then in the Queue name drop down list choose "Create SIB destination" + +In the Set queue attributes panel enter "HelloWorldService" for the Identifier and click Next, Next, and Finish + +That should take you back to the Queues panel where you can click OK to create the new JMS queue. + +Save the changes + +Restart WebSphere and you're done. + + + +Others... +--------- + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/pom.xml new file mode 100644 index 0000000000..48ff33be2d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/pom.xml @@ -0,0 +1,72 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-jms-webapp + war + Apache Tuscany SCA JMS HelloWorld Sample in a WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + ${pom.groupId} + tuscany-host-webapp + ${pom.version} + + + + ${pom.groupId} + tuscany-binding-jms-runtime + ${pom.version} + + + + ${pom.groupId} + tuscany-implementation-java-runtime + ${pom.version} + + + + org.apache.activemq + activemq-core + 5.1.0 + runtime + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/java/helloworld/HelloWorldClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/java/helloworld/HelloWorldClient.java new file mode 100644 index 0000000000..c24a741ee2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/java/helloworld/HelloWorldClient.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +/** + * The HelloWorld client implementation + */ +public class HelloWorldClient implements HelloWorldService { + + HelloWorldService helloWorldRef; + + public String sayHello(String name) { + System.out.println("HelloWorldClient.sayHello " + name); + return helloWorldRef.sayHello(name); + } + + public void setHelloWorldRef(HelloWorldService helloWorldRef) { + System.out.println("HelloWorldClient .setHelloWorldService " + helloWorldRef); + this.helloWorldRef = helloWorldRef; + } +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..2af978b9ce --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * The interface for the helloworld service + */ +@Remotable +public interface HelloWorldService { + public String sayHello(String name); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/java/helloworld/HelloWorldServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/java/helloworld/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..280388f443 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/java/helloworld/HelloWorldServiceImpl.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Service; + +/** + * This class implements the HelloWorld service. + */ +@Service(HelloWorldService.class) +public class HelloWorldServiceImpl implements HelloWorldService { + + public String sayHello(String name) { + System.out.println("HelloWorldServiceImpl .sayHello " + name); + return "Hello " + name; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/META-INF/context.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/META-INF/context.xml new file mode 100644 index 0000000000..2419887413 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/META-INF/context.xml @@ -0,0 +1,29 @@ + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/META-INF/sca-deployables/HelloWorld.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/META-INF/sca-deployables/HelloWorld.composite new file mode 100644 index 0000000000..f6328d156c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/META-INF/sca-deployables/HelloWorld.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..86710435ae --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,66 @@ + + + + + + + Apache Tuscany JMS Web Service Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + hello.jsp + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/hello.jsp b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/hello.jsp new file mode 100644 index 0000000000..bc6ef59a9b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jms-webapp/src/main/webapp/hello.jsp @@ -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. +--%> + +<%@ page import="org.apache.tuscany.sca.host.embedded.SCADomain"%> +<%@ page import="helloworld.HelloWorldService" %> + +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<% + SCADomain scaDomain = (SCADomain) application.getAttribute("org.apache.tuscany.sca.SCADomain"); + HelloWorldService helloWorldService = (HelloWorldService)scaDomain.getService(HelloWorldService.class, "HelloWorldClient"); +%> + +HelloWorld JMS sample + + + +If this sample is working correctly you should see "Hello World" on the next line... +

+<%= helloWorldService.sayHello("world") %> +

+If you do not see "Hello World" on the line above then there has been a problem. +

+The sample requires JMS resources be manually configured in the server environment, these are: +a JMS connection factory named "ConnectionFactory", and a destination queues named "HelloWorldService". +See the sample README file for more information. + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/README new file mode 100644 index 0000000000..07253d039b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/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-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-helloworld-jsonrpc-webapp + +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-webapp/ + 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-webapp.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-webapp +ant package + +This should result in a war file (sample-helloworld-jsonrpc-webapp.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-webapp + +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-webapp +mvn + +Again this should result in a war file (sample-helloworld-jsonrpc-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-20080910/samples/helloworld-jsonrpc-webapp/helloworld-jsonrpc.png b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/helloworld-jsonrpc.png new file mode 100644 index 0000000000..57f90aed01 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/helloworld-jsonrpc.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/helloworld-jsonrpc.svg b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/helloworld-jsonrpc.svg new file mode 100644 index 0000000000..6ef1f438fb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/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-20080910/samples/helloworld-jsonrpc-webapp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/pom.xml new file mode 100644 index 0000000000..8f4db306bd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/pom.xml @@ -0,0 +1,103 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-jsonrpc-webapp + war + Apache Tuscany SCA HelloWorld JSON-RPC Sample WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.4-SNAPSHOT + runtime + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + generate + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/java/helloworldjsonrpc/HelloWorldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/java/helloworldjsonrpc/HelloWorldService.java new file mode 100644 index 0000000000..3d8ea24f04 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/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-20080910/samples/helloworld-jsonrpc-webapp/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..35fd00fabd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/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-20080910/samples/helloworld-jsonrpc-webapp/src/main/resources/jsonrpc.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/resources/jsonrpc.composite new file mode 100644 index 0000000000..e895ab455d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/resources/jsonrpc.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/webapp/HelloWorldJSONRPC.html b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/webapp/HelloWorldJSONRPC.html new file mode 100644 index 0000000000..75dd9050fa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/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 + 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-20080910/samples/helloworld-jsonrpc-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/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-20080910/samples/helloworld-jsonrpc-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..267bed176c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + + + Apache Tuscany JSON-RPC HelloWorld Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + HelloWorldJSONRPC.html + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/webapp/style.css b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/src/main/webapp/style.css new file mode 100644 index 0000000000..1071583264 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsonrpc-webapp/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-20080910/samples/helloworld-jsp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/pom.xml new file mode 100644 index 0000000000..05c303a013 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/pom.xml @@ -0,0 +1,54 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-jsp + war + Apache Tuscany SCA Helloworld JSP Sample + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.4-SNAPSHOT + compile + + + + org.apache.tuscany.sca + tuscany-implementation-web-runtime + 1.4-SNAPSHOT + runtime + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/java/sample/HelloworldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/java/sample/HelloworldService.java new file mode 100644 index 0000000000..2b92fd4661 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/java/sample/HelloworldService.java @@ -0,0 +1,7 @@ +package sample; + +public interface HelloworldService { + + String sayHello(String name); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.java new file mode 100644 index 0000000000..be83d3b407 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.java @@ -0,0 +1,12 @@ +package sample; + +import org.osoa.sca.annotations.Service; + +@Service(HelloworldService.class) +public class HelloworldServiceImpl implements HelloworldService { + + public String sayHello(String name) { + return "Hello " + name; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/webapp/META-INF/sca-deployables/web.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/webapp/META-INF/sca-deployables/web.composite new file mode 100644 index 0000000000..16bc08fc10 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/webapp/META-INF/sca-deployables/web.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..46285614da --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + + + Apache Tuscany Helloworld JSP Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + hello.jsp + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/webapp/hello.jsp b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/webapp/hello.jsp new file mode 100644 index 0000000000..beac8e457f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-jsp/src/main/webapp/hello.jsp @@ -0,0 +1,36 @@ + +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib uri="http://www.osoa.org/sca/sca_jsp.tld" prefix="sca" %> + + + + + + +

Apache Tuscany Helloworld JSP Sample

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

+ + <%= service.sayHello("world") %> + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/README new file mode 100644 index 0000000000..184e67a239 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/README @@ -0,0 +1,114 @@ +Hello World JMS References Sample +================================= +This sample demonstrates an SCA reference that uses a JMS 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-service-jms 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-service-jms.jar helloworld.HelloWorldServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-service-jms.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-reference-jms.jar helloworld.HelloWorldJmsClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-reference-jms.jar helloworld.HelloWorldJmsClient + + +Sample Overview +--------------- +The sample provides a component that has a reference with a JMS binding. +The binding refers to JMS queue and communicates with a service +exposed by the helloworld-service-jms sample. + +helloworld-reference-jms/ + src/ + main/ + java/ + helloworld/ + HelloWorldService.java - interface description for + HelloWorldServiceComponent + HelloWorldServiceComponent.java - component implementation + HelloWorldJmsClient.java - starts the SCA Runtime and + deploys the helloworldwsjmsclient + .composite. It then calls the + HelloWorldServiceComponent + resources/ + helloworldjmsclient.composite - the SCA assembly for this sample + helloworldjms.composite - the SCA assembly for the server + that is used by the JUnit tests + logging.properties - log4j configuration file + test/ + java/ + helloworld/ + HelloWorldJMSClientTestCase.java - JUnit test case + helloworld-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-service-jms test. Take a look at the README in that sample +and you will see you need the following commands + +cd helloworld-service-jms +ant run + +Once done you can now compile and run this sample using the following commands; + +cd helloworld-reference-jms +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- +service-jms sample first as the JUnit test does this for you. + +cd helloworld-reference-jms +mvn + +You should see the following output from the test phase. + +run: + [java] Injected helloWorldService + [java] Called getGreetings + [java] javax.naming.NameNotFoundException: RequestQueue + ... + [java] Hello World + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/build.xml new file mode 100644 index 0000000000..4702beed0d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/helloworld-reference.png b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/helloworld-reference.png new file mode 100644 index 0000000000..ab80b1f91c Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/helloworld-reference.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/helloworld-reference.svg b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/helloworld-reference.svg new file mode 100644 index 0000000000..40f4e8f271 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/helloworld-reference.svg @@ -0,0 +1,144 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldjmsreference + + HelloWorldServiceComponent + + HelloWorldService ReferenceJMS + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/pom.xml new file mode 100644 index 0000000000..21ed69d7e9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/pom.xml @@ -0,0 +1,92 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-reference-jms + Apache Tuscany SCA HelloWorld Reference JMS Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + sample-helloworld-service-jms + 1.4-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + org.apache.activemq + apache-activemq + 4.1.1 + test + + + org.apache.activemq + activemq-web-demo + + + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..4cdcc1fd0b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/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-20080910/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldJmsClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldJmsClient.java new file mode 100644 index 0000000000..5bec27a137 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldJmsClient.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 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 HelloWorldJmsClient { + + public final static void main(String[] args) throws Exception { + //SCANode node = SCANodeFactory.createNodeWithComposite("helloworldjmsreference.composite"); + //HelloWorldService helloWorldService = node.getDomain().getService(HelloWorldService.class, "HelloWorldServiceComponent"); + + SCADomain scaDomain = SCADomain.newInstance("helloworldjmsreference.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-20080910/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..c0259c6e07 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * The interface for the helloworld service + */ +@Remotable +public interface HelloWorldService { + public String getGreetings(String name); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldServiceComponent.java new file mode 100644 index 0000000000..27cef47677 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/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-20080910/samples/helloworld-reference-jms/src/main/resources/helloworldjmsreference.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/resources/helloworldjmsreference.composite new file mode 100644 index 0000000000..3cf1104562 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/resources/helloworldjmsreference.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/resources/helloworldjmsservice.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/resources/helloworldjmsservice.composite new file mode 100644 index 0000000000..e692ef8e4c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/resources/helloworldjmsservice.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/resources/logging.properties b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/resources/logging.properties new file mode 100644 index 0000000000..a2a4067921 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/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: 582827 $ $Date: 2007-10-08 15:01:31 +0100 (Mon, 08 Oct 2007) $ +# + +# 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-20080910/samples/helloworld-reference-jms/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..e0ea596dd3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/test/java/helloworld/HelloWorldJmsClientTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/test/java/helloworld/HelloWorldJmsClientTestCase.java new file mode 100644 index 0000000000..f5380d9ccd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-reference-jms/src/test/java/helloworld/HelloWorldJmsClientTestCase.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package helloworld; + +import junit.framework.Assert; + +import org.apache.activemq.broker.BrokerService; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * Test case for helloworld web service client + */ +public class HelloWorldJmsClientTestCase { + + private HelloWorldService helloWorldService; + private HelloWorldService helloTuscanyService; + private SCADomain scaClientDomain; + private SCADomain scaServiceDomain; + private BrokerService jmsBroker; + + + @Before + public void startClient() throws Exception { + try { + startBroker(); + scaServiceDomain = SCADomain.newInstance("helloworldjmsservice.composite"); + scaClientDomain = SCADomain.newInstance("helloworldjmsreference.composite"); + helloWorldService = scaClientDomain.getService(HelloWorldService.class, "HelloWorldServiceComponent"); + + } catch (Throwable e) { + e.printStackTrace(); + } + } + + @Test + public void testWSClient() throws Exception { + String msg = helloWorldService.getGreetings("Smith"); + Assert.assertEquals("Hello Smith", msg); + Thread.sleep(2000); + } + + + @After + public void stopClient() throws Exception { + scaServiceDomain.close(); + scaClientDomain.close(); + if (jmsBroker != null) { + jmsBroker.stop(); + } + } + + protected void startBroker() throws Exception { + jmsBroker = new BrokerService(); + jmsBroker.setPersistent(false); + jmsBroker.setUseJmx(false); + jmsBroker.addConnector("tcp://localhost:61619"); + jmsBroker.start(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/README new file mode 100644 index 0000000000..49feabaa07 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/README @@ -0,0 +1,101 @@ +Hello World JMS Service Sample +============================== +This sample demonstrates an SCA service that uses a JMS 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-service-jms.jar helloworld.HelloWorldServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-service-jms.jar helloworld.HelloWorldServer + +Now the server is started you can use the helloworld-reference-jms sample to +exercise it. + +Sample Overview +--------------- +The sample provides a single component that is wired to a service with a +JMS binding. + +helloworld-service-jms/ + src/ + main/ + java/ + helloworld/ + HelloWorldService.java - interface description for + HelloWorldServiceComponent + HelloWorldImpl.java - component implementation + HelloWorldServer.java - starts the SCA Runtime and + deploys the helloworldjmsservice + .composite and then waits for the + service to be called via JMS + resources/ + helloworldjmsservice.composite - the SCA assembly for this sample + + test/ + java/ + helloworld/ + HelloWorldJMSServerTestCase.java- JUnit test case + helloworld-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-service-jms +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 JMS service via ActiveMQ which is +started automatically by the SCA runtime. To stop the server just press +enter. + +To exercise the service run up the helloworld-reference-jms sample. Take a look at +the README in that sample and you will see you need the following commands + +cd helloworld-reference-jms +ant run + +Building Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built +using Maven as follows. + +cd helloworld-service-jms +mvn + +You should see the following output + +... +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESSFUL +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 15 seconds +[INFO] Finished at: Wed Jul 02 12:50:24 BST 2008 +[INFO] Final Memory: 13M/51M +[INFO] ------------------------------------------------------------------------ + + +This shows that the module has compiled successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/build.xml new file mode 100644 index 0000000000..330de7f7e5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/helloworld-service.png b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/helloworld-service.png new file mode 100644 index 0000000000..ef27c71f54 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/helloworld-service.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/helloworld-service.svg b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/helloworld-service.svg new file mode 100644 index 0000000000..dd7a9dd87d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/helloworld-service.svg @@ -0,0 +1,139 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworld + + HelloWorldServiceComponent + HelloWorldServiceJMS + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/pom.xml new file mode 100644 index 0000000000..87c981b5c5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/pom.xml @@ -0,0 +1,85 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-service-jms + Apache Tuscany SCA HelloWorld Service JMS Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + compile + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + org.apache.activemq + apache-activemq + 4.1.1 + + + org.apache.activemq + activemq-web-demo + + + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..4cdcc1fd0b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/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-20080910/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldServer.java new file mode 100644 index 0000000000..d4ea391a00 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldServer.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 helloworld; + +import java.io.IOException; + +import org.apache.activemq.broker.BrokerService; +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) { + try { + BrokerService jmsBroker; + jmsBroker = new BrokerService(); + jmsBroker.setPersistent(false); + jmsBroker.setUseJmx(false); + jmsBroker.addConnector("tcp://localhost:61619"); + jmsBroker.start(); + + SCADomain scaDomain = SCADomain.newInstance("helloworldjmsservice.composite"); + + System.out.println("HelloWorld server started (press enter to shutdown)"); + System.in.read(); + + scaDomain.close(); + + jmsBroker.stop(); + System.out.println("HelloWorld server stopped"); + + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..4b019b21bf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/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; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public String getGreetings(String name); +} + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/resources/definitions.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/resources/definitions.xml new file mode 100644 index 0000000000..8c881ab0bb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/resources/definitions.xml @@ -0,0 +1,66 @@ + + + + + + + The general intent that a transport is available over which SOAP messages flow + + + + + + A JMS transport is required + + + + + + An HTTP transport is required + + + + + + + An HTTPS transport is required + + + + + + + org.apache.activemq.jndi.ActiveMQInitialContextFactory + tcp://localhost:61619 + QueueConnectionFactory + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/resources/helloworldjmsservice.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/resources/helloworldjmsservice.composite new file mode 100644 index 0000000000..3135cdc320 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/resources/helloworldjmsservice.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..3f9e00689e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/test/java/helloworld/HelloWorldJmsServerTestCaseOff.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/test/java/helloworld/HelloWorldJmsServerTestCaseOff.java new file mode 100644 index 0000000000..7930f98716 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-service-jms/src/test/java/helloworld/HelloWorldJmsServerTestCaseOff.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; + +import java.io.IOException; + +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 HelloWorldJmsServerTestCaseOff { + + private SCADomain scaDomain; + + @Before + public void startServer() throws Exception { + // ActiveMQModuleActivator.startBroker(); + scaDomain = SCADomain.newInstance("helloworldjmsservice.composite"); + } + + @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 { + if (scaDomain != null) { + scaDomain.close(); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/pom.xml new file mode 100644 index 0000000000..84494d1598 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/pom.xml @@ -0,0 +1,61 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-servlet + war + Apache Tuscany SCA Helloworld Sample using a servlet + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.4-SNAPSHOT + compile + + + + org.apache.tuscany.sca + tuscany-implementation-web-runtime + 1.4-SNAPSHOT + runtime + + + + javax.servlet + servlet-api + 2.3 + provided + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/java/sample/HelloworldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/java/sample/HelloworldService.java new file mode 100644 index 0000000000..2b92fd4661 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/java/sample/HelloworldService.java @@ -0,0 +1,7 @@ +package sample; + +public interface HelloworldService { + + String sayHello(String name); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/java/sample/HelloworldServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/java/sample/HelloworldServiceImpl.java new file mode 100644 index 0000000000..be83d3b407 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/java/sample/HelloworldServiceImpl.java @@ -0,0 +1,12 @@ +package sample; + +import org.osoa.sca.annotations.Service; + +@Service(HelloworldService.class) +public class HelloworldServiceImpl implements HelloworldService { + + public String sayHello(String name) { + return "Hello " + name; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/java/sample/HelloworldServlet.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/java/sample/HelloworldServlet.java new file mode 100644 index 0000000000..0cdcc32e70 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/java/sample/HelloworldServlet.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +import java.io.IOException; +import java.io.Writer; + +import javax.servlet.ServletConfig; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.osoa.sca.ComponentContext; +import org.osoa.sca.annotations.Reference; + +/** + */ +public class HelloworldServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + @Reference + protected HelloworldService service; + + @Override + public void init(ServletConfig config) { + if (service == null) { + // The helloworldService reference will only be injected from the @Reference + // annotation in containers supporting SCA "deep" integration. In other + // environments in can be looked up from the ComponentContext. + ComponentContext cc = (ComponentContext)config.getServletContext().getAttribute("org.osoa.sca.ComponentContext"); + service = cc.getService(HelloworldService.class, "service"); + } + } + + @Override + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { + + String name = request.getParameter("name"); + String greeting = service.sayHello(name); + + Writer out = response.getWriter(); + out.write("Apache Tuscany Helloworld Servlet Sample"); + out.write("

Apache Tuscany Helloworld Servlet Sample

"); + out.write("
Result: " + greeting); + out.write(""); + out.flush(); + out.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/webapp/META-INF/sca-deployables/web.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/webapp/META-INF/sca-deployables/web.composite new file mode 100644 index 0000000000..23fd33a408 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/webapp/META-INF/sca-deployables/web.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..28cfdd3f6c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,52 @@ + + + + + + Apache Tuscany Helloworld Servlet Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + HelloworldServlet + sample.HelloworldServlet + + + + HelloworldServlet + /HelloworldServlet + + + + hello.html + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/webapp/hello.html b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/webapp/hello.html new file mode 100644 index 0000000000..c4484916aa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-servlet/src/main/webapp/hello.html @@ -0,0 +1,46 @@ + + + + +Apache Tuscany Helloworld Servlet Sample + + + + +

Apache Tuscany Helloworld Servlet Sample

+ +
+ + + + + + + + +
Enter your name: + +
+ +
+
+ + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/pom.xml new file mode 100644 index 0000000000..54b422d64f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/pom.xml @@ -0,0 +1,68 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-web-callback + war + Apache Tuscany SCA Web 2.0 Callbacks Sample + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.4-SNAPSHOT + compile + + + + org.apache.tuscany.sca + tuscany-implementation-web-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-dwr + 1.4-SNAPSHOT + runtime + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/java/sample/HelloworldCallback.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/java/sample/HelloworldCallback.java new file mode 100644 index 0000000000..661f703dc8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/java/sample/HelloworldCallback.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package sample; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface HelloworldCallback { + + @OneWay + void sayHelloCallback(String reply); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/java/sample/HelloworldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/java/sample/HelloworldService.java new file mode 100644 index 0000000000..d2c1fc2def --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/java/sample/HelloworldService.java @@ -0,0 +1,14 @@ +package sample; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +@Remotable +@Callback(HelloworldCallback.class) +public interface HelloworldService { + + @OneWay + void sayHello(String name); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/java/sample/HelloworldServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/java/sample/HelloworldServiceImpl.java new file mode 100644 index 0000000000..8b52e42754 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/java/sample/HelloworldServiceImpl.java @@ -0,0 +1,27 @@ +package sample; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Service; + +@Service(HelloworldService.class) +public class HelloworldServiceImpl implements HelloworldService { + + @Callback + public HelloworldCallback callback; + + public void sayHello(final String name) { + Thread t = new Thread(new Runnable() { + public void run() { + for (int i=0; i<5; i++) { + callback.sayHelloCallback(i + "Hello " + name); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }}); + t.start(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/webapp/META-INF/sca-deployables/web.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/webapp/META-INF/sca-deployables/web.composite new file mode 100644 index 0000000000..fdd5a95f58 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/webapp/META-INF/sca-deployables/web.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..f29262a147 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + + + Apache Tuscany Helloworld Servlet Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + hello.html + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/webapp/hello.html b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/webapp/hello.html new file mode 100644 index 0000000000..6d4c17626b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web-callback/src/main/webapp/hello.html @@ -0,0 +1,63 @@ + + + + + Apache Tuscany Helloworld Web2.0 Callbacks Sample + + + + + + + +

Apache Tuscany Helloworld Web2.0 Callbacks Sample

+ + + + + + + + + + + + +
Enter your name: + +
+ +
+
+
+ + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/pom.xml new file mode 100644 index 0000000000..06b05a7c0e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/pom.xml @@ -0,0 +1,68 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-web + war + Apache Tuscany SCA Helloworld Web Sample + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.4-SNAPSHOT + compile + + + + org.apache.tuscany.sca + tuscany-implementation-web-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.4-SNAPSHOT + runtime + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/java/sample/HelloworldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/java/sample/HelloworldService.java new file mode 100644 index 0000000000..2b92fd4661 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/java/sample/HelloworldService.java @@ -0,0 +1,7 @@ +package sample; + +public interface HelloworldService { + + String sayHello(String name); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/java/sample/HelloworldServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/java/sample/HelloworldServiceImpl.java new file mode 100644 index 0000000000..be83d3b407 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/java/sample/HelloworldServiceImpl.java @@ -0,0 +1,12 @@ +package sample; + +import org.osoa.sca.annotations.Service; + +@Service(HelloworldService.class) +public class HelloworldServiceImpl implements HelloworldService { + + public String sayHello(String name) { + return "Hello " + name; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/webapp/META-INF/sca-deployables/web.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/webapp/META-INF/sca-deployables/web.composite new file mode 100644 index 0000000000..20cebc2d53 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/webapp/META-INF/sca-deployables/web.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..f29262a147 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + + + Apache Tuscany Helloworld Servlet Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + hello.html + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/webapp/hello.html b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/webapp/hello.html new file mode 100644 index 0000000000..83ac0ae576 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-web/src/main/webapp/hello.html @@ -0,0 +1,62 @@ + + + + + Apache Tuscany Helloworld Web Sample + + + + + + + +

Apache Tuscany Helloworld Web Sample

+ + + + + + + + + + + + +
Enter your name: + +
+ +
+
+
+ + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/README new file mode 100644 index 0000000000..66040004f8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/README @@ -0,0 +1 @@ +http://localhost:8080/sample-helloworld-ws-service-webapp/SCA/HelloWorldService?wsdl diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/build.xml new file mode 100644 index 0000000000..bdb341d26a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/build.xml @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/pom.xml new file mode 100644 index 0000000000..1651656c64 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + + + sample-helloworld-ws-service-webapp + Apache Tuscany SCA HelloWorld Web Service Sample Webapp + war + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.4-SNAPSHOT + provided + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..0de3c70303 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/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-20080910/samples/helloworld-ws-deep-webapp/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..268d90e910 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public String getGreetings(String name); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/resources/META-INF/sca-deployables/helloworldws.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/resources/META-INF/sca-deployables/helloworldws.composite new file mode 100644 index 0000000000..114608e4d8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/resources/META-INF/sca-deployables/helloworldws.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..0b95fbd14f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..182fd38fd9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-deep-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,27 @@ + + + + + + + Apache Tuscany HelloWorld Web Service Sample + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/README new file mode 100644 index 0000000000..abf10ef1f2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/README @@ -0,0 +1,127 @@ +Hello World Web Service References Sample +========================================= +This sample demonstrates an SCA reference that uses a web service binding running +over a JMS protocl. + +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-jms 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-jms.jar helloworld.HelloWorldServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-service-jms.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-jms.jar helloworld.HelloWorldJmsClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-reference-jms.jar helloworld.HelloWorldJmsClient + + +Sample Overview +--------------- +The sample provides two components that are have a reference with a +web service binding. The binding refers to WSDL that identifies the service +exposed by the helloworld-ws-service-jms sample. + +helloworld-ws-reference-jms/ + src/ + main/ + java/ + helloworld/ + HelloWorldService.java - interface description for + HelloWorldServiceComponent + HelloWorldServiceComponent.java - component implementation + HelloWorldJmsClient.java - starts the SCA Runtime and + deploys the helloworldwsjmsclient + .composite. It then calls the + HelloWorldServiceComponent + resources/ + wsdl + helloworld.wsdl - the service description that the + SCA reference uses to bind to + helloworldwsjmsclient.composite - the SCA assembly for this sample + helloworldwsjms.composite - the SCA assembly for the server + that is used by the JUnit tests + logging.properties - log4j configuration file + test/ + java/ + helloworld/ + HelloWorldJMSClientTestCase.java - JUnit test case + 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-jms test. Take a look at the README in that sample +and you will see you need the following commands + +cd helloworld-ws-service-jms +ant run + +Once done you can now compile and run this sample using the following commands; + +cd helloworld-ws-reference-jms +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-jms sample first as the JUnit test does this for you. + +cd helloworld-ws-reference-jms +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running helloworld.HelloWorldJmsClientTestCase +08-Jan-2008 10:40:15 org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceProvide +r start +INFO: Axis2 JMS URL=jms:/queue.sample?transport.jms.ConnectionFactoryJNDIName=Qu +eueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.Active +MQInitialContextFactory&java.naming.provider.url=tcp://localhost:61619 +Injected helloWorldService +Called getGreetings +Injected helloWorldService +Called getGreetings +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 11.89 sec + + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/build.xml new file mode 100644 index 0000000000..4f83c8ae9d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/helloworld-ws-reference.png b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/helloworld-ws-reference.png new file mode 100644 index 0000000000..bd2bba41db Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/helloworld-ws-reference.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/helloworld-ws-reference.svg b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/helloworld-ws-reference.svg new file mode 100644 index 0000000000..333ad53e0a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/helloworld-ws-reference.svg @@ -0,0 +1,150 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldwsclient + + HelloWorldServiceComponent + + + HelloWorldService + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/pom.xml new file mode 100644 index 0000000000..8015eddca9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/pom.xml @@ -0,0 +1,92 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-ws-reference-jms + Apache Tuscany SCA HelloWorld Web Service Reference JMS Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + sample-helloworld-ws-service-jms + 1.4-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + org.apache.activemq + apache-activemq + 4.1.1 + test + + + org.apache.activemq + activemq-web-demo + + + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..4cdcc1fd0b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/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-20080910/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldJmsClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldJmsClient.java new file mode 100644 index 0000000000..b3db243a1f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldJmsClient.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 HelloWorldJmsClient { + + public final static void main(String[] args) throws Exception { + SCADomain scaDomain = SCADomain.newInstance("helloworldwsjmsclient.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-20080910/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..db0c947cf7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * The interface for the helloworld service + */ +@Remotable +public interface HelloWorldService { + public String getGreetings(String name); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldServiceComponent.java new file mode 100644 index 0000000000..0dee19550b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/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-20080910/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjms.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjms.composite new file mode 100644 index 0000000000..d029ba3e1c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjms.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjmsclient.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjmsclient.composite new file mode 100644 index 0000000000..a4eb217310 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjmsclient.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/resources/logging.properties b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/resources/logging.properties new file mode 100644 index 0000000000..3dca310cdb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/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-20080910/samples/helloworld-ws-reference-jms/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..013a55b61e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/test/java/helloworld/HelloWorldJmsClientTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/test/java/helloworld/HelloWorldJmsClientTestCase.java new file mode 100644 index 0000000000..12b0716b5d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-jms/src/test/java/helloworld/HelloWorldJmsClientTestCase.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package helloworld; + +import junit.framework.Assert; + +import org.apache.activemq.broker.BrokerService; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * Test case for helloworld web service client + */ +public class HelloWorldJmsClientTestCase { + + private HelloWorldService helloWorldService; + private HelloWorldService helloTuscanyService; + private SCADomain scaClientDomain; + private SCADomain scaServiceDomain; + private BrokerService jmsBroker; + + + @Before + public void startClient() throws Exception { + try { + startBroker(); + scaServiceDomain = SCADomain.newInstance("helloworldwsjms.composite"); + scaClientDomain = SCADomain.newInstance("helloworldwsjmsclient.composite"); + helloWorldService = scaClientDomain.getService(HelloWorldService.class, "HelloWorldServiceComponent"); + helloTuscanyService = scaClientDomain.getService(HelloWorldService.class, "HelloTuscanyServiceComponent"); + + } catch (Throwable e) { + e.printStackTrace(); + } + } + + @Test + public void testWSClient() throws Exception { + String msg = helloWorldService.getGreetings("Smith"); + Assert.assertEquals("Hello Smith", msg); + msg = helloTuscanyService.getGreetings("Green"); + Assert.assertEquals("Hello Green", msg); + + Thread.sleep(2000); + } + + + @After + public void stopClient() throws Exception { + scaServiceDomain.close(); + scaClientDomain.close(); + if (jmsBroker != null) { + jmsBroker.stop(); + } + } + + protected void startBroker() throws Exception { + jmsBroker = new BrokerService(); + jmsBroker.setPersistent(false); + jmsBroker.setUseJmx(false); + jmsBroker.addConnector("tcp://localhost:61619"); + jmsBroker.start(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/README new file mode 100644 index 0000000000..13c89ab2f6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/README @@ -0,0 +1,178 @@ +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] 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 +14-Jan-2008 14:06:12 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +14-Jan-2008 14:06:12 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +14-Jan-2008 14:06:12 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_1_4.xsd +14-Jan-2008 14:06:12 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/xml.xsd +14-Jan-2008 14:06:12 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +14-Jan-2008 14:06:12 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +14-Jan-2008 14:06:12 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/web-app_2_4.xsd +14-Jan-2008 14:06:12 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +14-Jan-2008 14:06:12 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_client +_1_1.xsd +14-Jan-2008 14:06:12 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:06:12 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:06:12 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8085/HelloWorldService +Injected helloWorldService +Called getGreetings +14-Jan-2008 14:06:14 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:06:17 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +14-Jan-2008 14:06:17 org.apache.catalina.loader.WebappLoader start +INFO: Dual registration of jndi stream handler: factory already defined +14-Jan-2008 14:06:17 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +14-Jan-2008 14:06:17 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_1_4.xsd +14-Jan-2008 14:06:17 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/xml.xsd +14-Jan-2008 14:06:17 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +14-Jan-2008 14:06:17 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +14-Jan-2008 14:06:17 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/web-app_2_4.xsd +14-Jan-2008 14:06:17 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +14-Jan-2008 14:06:17 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_client +_1_1.xsd +14-Jan-2008 14:06:17 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:06:17 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:06:17 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8085/HelloWorldService +Injected helloWorldService +Called getGreetings +14-Jan-2008 14:06:18 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8085 +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 13.625 sec + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/helloworld-ws-reference.png b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/helloworld-ws-reference.png new file mode 100644 index 0000000000..bd2bba41db Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/helloworld-ws-reference.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/helloworld-ws-reference.svg b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/helloworld-ws-reference.svg new file mode 100644 index 0000000000..354ffbae8f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/helloworld-ws-reference.svg @@ -0,0 +1,150 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldwsclient + + HelloWorldServiceComponent + + + HelloWorldService + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/pom.xml new file mode 100644 index 0000000000..6f672b5054 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-ws-reference-lean + Apache Tuscany SCA HelloWorld Web Service Reference Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + sample-helloworld-ws-service + 1.4-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient.java new file mode 100644 index 0000000000..f8d66876fa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +/** + * The HelloWorld client implementation + */ +@Scope("COMPOSITE") @EagerInit +public class HelloWorldClient { + + static HelloWorldService helloWorldService; + + @Reference + public void setHelloWorldService(HelloWorldService service) { + helloWorldService = service; + } + + public final static void main(String[] args) throws Exception { + SCADomain scaDomain = SCADomain.newInstance("helloworldwsclient.composite"); + + String value = helloWorldService.getGreetings("World"); + System.out.println(value); + + scaDomain.close(); + } +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient2.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient2.java new file mode 100644 index 0000000000..13a31b6391 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient2.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 helloworld; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +/** + * The HelloWorld client implementation + */ +@Scope("COMPOSITE") @EagerInit +public class HelloWorldClient2 { + + private static HelloWorldClient2 client; + + @Reference + public HelloWorldService helloWorldService; + + public HelloWorldClient2() { + client = this; + } + + public final static void main(String[] args) throws Exception { + SCADomain scaDomain = SCADomain.newInstance("helloworldwsclient2.composite"); + + client.doit(args); + + scaDomain.close(); + } + + void doit(String[] args) { + String value = helloWorldService.getGreetings("World"); + System.out.println(value); + } +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient3.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient3.java new file mode 100644 index 0000000000..6d1722095b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient3.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +/** + * The HelloWorld client implementation + */ +@Scope("COMPOSITE") @EagerInit +public class HelloWorldClient3 { + + @Reference + public HelloWorldService helloWorldService; + + public final static void main(String[] args) throws Exception { + SCADomain scaDomain = SCADomain.newInstance("helloworldwsclient3.composite"); + + scaDomain.getService(HelloWorldClient3.class, "HelloWorldClient3").doit(args); + + scaDomain.close(); + } + + public void doit(String[] args) { + String value = helloWorldService.getGreetings("World"); + System.out.println(value); + } +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient4.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient4.java new file mode 100644 index 0000000000..3def5194a5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient4.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 helloworld; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Scope; + +/** + * The HelloWorld client implementation + */ +@Scope("COMPOSITE") @EagerInit +public class HelloWorldClient4 { + + static ComponentContext clientContext; + + @Context + public void setContext(ComponentContext context) { + clientContext = context; + } + + public final static void main(String[] args) throws Exception { + SCADomain scaDomain = SCADomain.newInstance("helloworldwsclient4.composite"); + + HelloWorldService helloWorldService = clientContext.getService(HelloWorldService.class, "helloWorldService"); + String value = helloWorldService.getGreetings("World"); + System.out.println(value); + + scaDomain.close(); + } + + public void doit(String[] args) { + } +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient5.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient5.java new file mode 100644 index 0000000000..7c1853566f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldClient5.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +/** + * The HelloWorld client implementation + */ +@Scope("COMPOSITE") @EagerInit +public class HelloWorldClient5 { + + @Reference + public HelloWorldService helloWorldService; + + public final static void main(String[] args) throws Exception { + SCADomain scaDomain = SCADomain.newInstance("helloworldwsclient5.composite"); + + scaDomain.close(); + } + + @Init + public void doit() { + String value = helloWorldService.getGreetings("World"); + System.out.println(value); + } +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..db0c947cf7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * The interface for the helloworld service + */ +@Remotable +public interface HelloWorldService { + public String getGreetings(String name); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient.composite new file mode 100644 index 0000000000..991e4b4881 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient2.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient2.composite new file mode 100644 index 0000000000..6ea14602b3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient2.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient3.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient3.composite new file mode 100644 index 0000000000..3d6364f55f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient3.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient4.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient4.composite new file mode 100644 index 0000000000..106e9db988 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient4.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient5.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient5.composite new file mode 100644 index 0000000000..bbac4c3703 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/helloworldwsclient5.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/logging.properties b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/logging.properties new file mode 100644 index 0000000000..3dca310cdb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/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-20080910/samples/helloworld-ws-reference-lean/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..662c9affac --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/test/java/helloworld/HelloWorldClientTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/test/java/helloworld/HelloWorldClientTestCase.java new file mode 100644 index 0000000000..51b70f47c2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/test/java/helloworld/HelloWorldClientTestCase.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package 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 extends HelloWorldClient { + + private SCADomain scaDomain; + private SCATestCaseRunner server; + + @Before + public void startClient() throws Exception { + scaDomain = SCADomain.newInstance("helloworldwsclient.composite"); + + server = new SCATestCaseRunner(HelloWorldTestServer.class); + server.before(); + } + + @Test + public void testWSClient() throws Exception { + String msg = helloWorldService.getGreetings("Smith"); + Assert.assertEquals("Hello Smith", msg); + } + + @After + public void stopClient() throws Exception { + server.after(); + scaDomain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/test/java/helloworld/HelloWorldTestServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/src/test/java/helloworld/HelloWorldTestServer.java new file mode 100644 index 0000000000..8226ec884e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-lean/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("META-INF/sca-deployables/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-20080910/samples/helloworld-ws-reference-secure/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/README new file mode 100644 index 0000000000..167991c8f7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/README @@ -0,0 +1,176 @@ +Hello World Secure 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-secure.jar helloworld.HelloWorldServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-service-secure.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-secure.jar helloworld.HelloWorldClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-reference-secure.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-secure sample. This sample invokes a +secure web-serivce and hence specifies a policy intent named 'authentication' +which is fulfilled by a suitable policyset that is defined for the SCA Domain. +Over the helloworld-ws-reference sample, this sample demonstrate generally +the use of policy intents and policy sets in Tuscany taking the specific instance +of a security policy. + +Note : +------ +The policies mentioned and supported are instances of Tuscany specified policies and +not instnaces of WS-Policy. + +helloworld-ws-reference-secure/ + 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 + ClientPWCBHandler.java - Callback handler class to provide client password. The + handle(Callback[] callbacks) method of this class is where + code for accessing user registries and retrieving passwords + for given user identifiers can be encapsulated. For example + here is where one could access LDAP registries to obtain or + compare user identities and passwords. + + 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 + definitions.xml - the SCA Definitions file that contains intents and policysets + defined for the SCA Domain + test/ + java/ + helloworld/ + HelloWorldClientTestCase.java - JUnit test case + HelloWorldServerTest.java - starts the Web service + helloworld-ws-reference-secure.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-secure test. Take a look at the README in that sample +and you will see you need the following commands + +cd helloworld-ws-service-secure +ant run + +Once done you can now compile and run this sample using the following commands; + +cd helloworld-ws-reference-secure +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] *** Calling Client UserId/Password Handler .... + [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-secure sample first as Maven does this for you. + +cd helloworld-ws-reference-secure +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 +*** Calling Client UserId/Password Handler .... +*** Calling Server User/Passwd Handler.... +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. Also note that the client side and server side +callback handlers for authentication have been called. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/build.xml new file mode 100644 index 0000000000..38f1b7549d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/helloworld-ws-reference-secure.png b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/helloworld-ws-reference-secure.png new file mode 100644 index 0000000000..bd2bba41db Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/helloworld-ws-reference-secure.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/helloworld-ws-reference-secure.svg b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/helloworld-ws-reference-secure.svg new file mode 100644 index 0000000000..333ad53e0a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/helloworld-ws-reference-secure.svg @@ -0,0 +1,150 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldwsclient + + HelloWorldServiceComponent + + + HelloWorldService + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/pom.xml new file mode 100644 index 0000000000..8c624a72b3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/pom.xml @@ -0,0 +1,85 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-ws-reference-secure + Apache Tuscany SCA HelloWorld Secure Web Service Reference Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.ws.security + wss4j + 1.5.3 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + sample-helloworld-ws-service-secure + 1.4-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/java/helloworld/ClientPWCBHandler.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/java/helloworld/ClientPWCBHandler.java new file mode 100644 index 0000000000..0f1ebf46d6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/java/helloworld/ClientPWCBHandler.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + */ +public class ClientPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Client UserId/Password Handler .... "); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + System.out.println("User Id = " + pwcb.getIdentifer()); + pwcb.setPassword("TuscanyWsUserPasswd"); + System.out.println("Set Password = " + pwcb.getPassword()); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldClient.java new file mode 100644 index 0000000000..a21619fc8a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldClient.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.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); + + helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldWsPolicyServiceComponent"); + value = helloWorldService.getGreetings("WsPolicyWorld"); + System.out.println(value); + + scaDomain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..c0259c6e07 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * The interface for the helloworld service + */ +@Remotable +public interface HelloWorldService { + public String getGreetings(String name); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldServiceComponent.java new file mode 100644 index 0000000000..27cef47677 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/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-20080910/samples/helloworld-ws-reference-secure/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler new file mode 100644 index 0000000000..8b089c7222 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler @@ -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. +# +# PolicyHandlerClasses to interpret specific PolicyModels against specific QoS infrastructures +# handler classname;qname=;model= +org.apache.tuscany.sca.policy.security.ws.Axis2ConfigParamPolicyHandler;intent=http://helloworld#wsAuthentication,model=org.apache.tuscany.sca.policy.security.ws.Axis2ConfigParamPolicy +org.apache.tuscany.sca.policy.security.ws.WSSecurityPolicyHandler;intent=http://helloworld#wsIntegrity,model=org.apache.neethi.Policy \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/definitions.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/definitions.xml new file mode 100644 index 0000000000..0ab3a5a9f1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/definitions.xml @@ -0,0 +1,203 @@ + + + + + + + + + + UsernameToken + TuscanyWsUser + helloworld.ClientPWCBHandler" + + PasswordText + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TuscanyWsUser + TuscanyWsUser + helloworld.ClientPWCBHandler + + + + JKS + helloworldKeys.jks + TuscanyWsUserPasswd + + + + + + + + + + + + + + + + + UsernameToken + helloworld.ServerPWCBHandler + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TuscanyWsUser + TuscanyWsUser + helloworld.ServerPWCBHandler + + + + JKS + helloworldKeys.jks + TuscanyWsUserPasswd + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/helloworldKeys.jks b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/helloworldKeys.jks new file mode 100644 index 0000000000..0b4f2399f0 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/helloworldKeys.jks differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/helloworldwsclient.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/helloworldwsclient.composite new file mode 100644 index 0000000000..904befaf60 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/helloworldwsclient.composite @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/logging.properties b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/logging.properties new file mode 100644 index 0000000000..3a4b43222d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/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: 463856 $ $Date: 2006-10-14 03:54:29 +0530 (Sat, 14 Oct 2006) $ +# + +# 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-20080910/samples/helloworld-ws-reference-secure/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..e6fcc6f4a6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/test/java/helloworld/HelloWorldClientTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/test/java/helloworld/HelloWorldClientTestCase.java new file mode 100644 index 0000000000..848c41d1c7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/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-20080910/samples/helloworld-ws-reference-secure/src/test/java/helloworld/HelloWorldTestServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/src/test/java/helloworld/HelloWorldTestServer.java new file mode 100644 index 0000000000..21f2166560 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference-secure/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-20080910/samples/helloworld-ws-reference/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/README new file mode 100644 index 0000000000..13c89ab2f6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/README @@ -0,0 +1,178 @@ +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] 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 +14-Jan-2008 14:06:12 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +14-Jan-2008 14:06:12 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +14-Jan-2008 14:06:12 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_1_4.xsd +14-Jan-2008 14:06:12 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/xml.xsd +14-Jan-2008 14:06:12 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +14-Jan-2008 14:06:12 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +14-Jan-2008 14:06:12 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/web-app_2_4.xsd +14-Jan-2008 14:06:12 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +14-Jan-2008 14:06:12 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_client +_1_1.xsd +14-Jan-2008 14:06:12 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:06:12 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:06:12 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8085/HelloWorldService +Injected helloWorldService +Called getGreetings +14-Jan-2008 14:06:14 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:06:17 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +14-Jan-2008 14:06:17 org.apache.catalina.loader.WebappLoader start +INFO: Dual registration of jndi stream handler: factory already defined +14-Jan-2008 14:06:17 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +14-Jan-2008 14:06:17 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_1_4.xsd +14-Jan-2008 14:06:17 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/xml.xsd +14-Jan-2008 14:06:17 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +14-Jan-2008 14:06:17 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +14-Jan-2008 14:06:17 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/web-app_2_4.xsd +14-Jan-2008 14:06:17 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +14-Jan-2008 14:06:17 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_client +_1_1.xsd +14-Jan-2008 14:06:17 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:06:17 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:06:17 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8085/HelloWorldService +Injected helloWorldService +Called getGreetings +14-Jan-2008 14:06:18 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8085 +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 13.625 sec + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/build.xml new file mode 100644 index 0000000000..71ee66b31e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/helloworld-ws-reference.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/helloworld-ws-reference/helloworld-ws-reference.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/helloworld-ws-reference.svg b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/helloworld-ws-reference/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/pom.xml new file mode 100644 index 0000000000..f8da8ad6e0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-ws-reference + Apache Tuscany SCA HelloWorld Web Service Reference Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + sample-helloworld-ws-service + 1.4-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..db0c947cf7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * The interface for the helloworld service + */ +@Remotable +public interface HelloWorldService { + public String getGreetings(String name); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/main/resources/logging.properties b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/helloworld-ws-reference/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..662c9affac --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldClientTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldTestServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldTestServer.java new file mode 100644 index 0000000000..8226ec884e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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("META-INF/sca-deployables/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-20080910/samples/helloworld-ws-sdo-webapp/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/README new file mode 100644 index 0000000000..aa4819927a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/README @@ -0,0 +1,92 @@ +Hello World Web Service SDO WebApp Sample +========================================= +This sample demonstrates an SCA web service binding which works with +SDO and runs as a web application. + +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 is built and copied to your web app container. +See the sections below for instructions on building the war. + +Once the web app is deployed use your browser to visit the following URL; + + http://localhost:8080/sample-helloworld-ws-sdo-webapp + +The port and hostname will of course vary depending on your local installation. + +The resulting web page displayed should show: + + Hello John Smith, Jane Doe! + +Sample Overview +--------------- +The sample builds a war with a single JSP (HelloWorld.jsp). This JSP +calls an SCA component with an SDO parameter. This in turn calls another +SCA component with the SDO parameter. The contents of the SDO are then +returned as a simple string. This sample shows how SDO objects can +be passed into and between services in the context of a web application. + + +helloworld-jsonrpc-webapp/ + src/ + main/ + java/ + helloworld/ + HelloWorld.java - service interface + HelloWorldComponent.java - first service implementation + HelloWorldmpl.java - second service implementation + resources/ + wsdl/ + helloworld.wsdl - the web services description + helloworld.xsd - the SDO description + helloworldws.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 + HelloWorld.jsp - the web application that calls the + SCA service passing in an SDO + + helloworld-ws-sdo-webapp.png - a pictorial representation of the + sample .composite file + 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 helloworld-ws-sdo-webapp +ant package + +This should result in a war file (sample-helloworld-ws-sdo-webapp.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-ws-sdo-webapp + +The port and hostname will of course vary depending on your local installation. + +Building 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-webapp +mvn + +That should end with "BUILD SUCCESSFUL" and create the target/sample-helloworld-ws-sdo-webapp.war +which you can copy to your server. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/build.xml new file mode 100644 index 0000000000..386008e707 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/build.xml @@ -0,0 +1,99 @@ + + +]> + + + &buildDependency; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/helloworld-ws-sdo-webapp.png b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/helloworld-ws-sdo-webapp.png new file mode 100644 index 0000000000..2590f02a45 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/helloworld-ws-sdo-webapp.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/helloworld-ws-sdo-webapp.svg b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/helloworld-ws-sdo-webapp.svg new file mode 100644 index 0000000000..56a29db23c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/helloworld-ws-sdo-webapp.svg @@ -0,0 +1,221 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldws + + HelloWorldServiceComponent + + + + HelloWorldImpl + + + SDO + HelloWorld.jsp + + + sample-helloworld-ws-sdo-webapp.war + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/pom.xml new file mode 100644 index 0000000000..7d4fdd95e6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/pom.xml @@ -0,0 +1,200 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-ws-sdo-webapp + war + Apache Tuscany SCA HelloWorld Web Service SDO Sample WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4-SNAPSHOT + + + + org.apache.tuscany.sdo + tuscany-sdo-api-r2.1 + 1.1.1 + + + org.apache.tuscany.sdo + tuscany-sdo-lib + 1.1.1 + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.1.1 + + + org.apache.tuscany.sca + tuscany-databinding-sdo + 1.4-SNAPSHOT + compile + + + + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + junit + junit + 4.2 + test + + + + org.codehaus.woodstox + wstx-asl + 3.2.1 + runtime + + + + + + ${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.1.1 + + + generate-helloworld-sdo + generate-sources + + + + ${basedir}/src/main/resources/wsdl/helloworld.xsd + helloworld.type + Type + true + + + ${basedir}/src/main/resources/wsdl/helloworld.wsdl + helloworld + Helloworld + true + + + + + generate + + + + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + true + + + generate + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorld.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorld.java new file mode 100644 index 0000000000..eb82418516 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorld.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. + */ + +/** + * HelloWorld.java + * + * This file was auto-generated from WSDL + * by the Apache Axis2 version: #axisVersion# #today# + */ +package helloworld; + +import org.osoa.sca.annotations.Remotable; + +/* + * HelloWorld java interface + */ + +@Remotable +public interface HelloWorld { + + /** + * Auto generated method signatures + * + * @param getGreetings + */ + public java.lang.String getGreetings(helloworld.Party getGreetings); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorldComponent.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorldComponent.java new file mode 100644 index 0000000000..fea4e2a16c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorldComponent.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + + +public class HelloWorldComponent implements HelloWorld { + + HelloWorld helloWorld; + + public String getGreetings(Party party) { + System.out.println("Called getGreetings"); + return helloWorld.getGreetings(party); + } + + public HelloWorld getHelloWorld() { + System.out.println("Got Injected helloWorld"); + return helloWorld; + } + + public void setHelloWorld(HelloWorld helloWorld) { + System.out.println("Injected helloWorld"); + this.helloWorld = helloWorld; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..3d6576aca0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorldImpl.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 helloworld; + +import java.util.List; + +import org.osoa.sca.annotations.Service; + +@Service(HelloWorld.class) +public class HelloWorldImpl implements HelloWorld { + + public String getGreetings(Party party) { + System.out.println("Greeting party"); + StringBuffer greetings = new StringBuffer(); + greetings.append("Hello "); + List people = party.getPeople(); + int i=0; + for (Person person : people) { + greetings.append(person.getFirstName()); + greetings.append(" "); + greetings.append(person.getLastName()); + i++; + if (i < people.size()) { + greetings.append(", "); + } + } + greetings.append("!"); + + return greetings.toString(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/resources/helloworldws.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/resources/helloworldws.composite new file mode 100644 index 0000000000..34396b1b02 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/resources/helloworldws.composite @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..fe79094b94 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/resources/wsdl/helloworld.xsd b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/resources/wsdl/helloworld.xsd new file mode 100644 index 0000000000..a0b7c37cd9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/resources/wsdl/helloworld.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/webapp/HelloWorld.jsp b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/webapp/HelloWorld.jsp new file mode 100644 index 0000000000..4657c6cdc1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/webapp/HelloWorld.jsp @@ -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. +--%> + +<%@ page import="org.apache.tuscany.sca.host.embedded.SCADomain"%> +<%@ page import="helloworld.HelloWorld" %> +<%@ page import="helloworld.HelloworldFactory"%> +<%@ page import="helloworld.Party"%> +<%@ page import="helloworld.Person"%> + +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<% + SCADomain scaDomain = (SCADomain) application.getAttribute("org.apache.tuscany.sca.SCADomain"); + HelloWorld helloWorld = (HelloWorld)scaDomain.getService(HelloWorld.class, "HelloWorldServiceComponent"); +%> + +Hello World SDO sample + + +<% + Party party = HelloworldFactory.INSTANCE.createParty(); + Person person = HelloworldFactory.INSTANCE.createPerson(); + person.setFirstName("John"); + person.setLastName("Smith"); + party.getPeople().add(person); + person = HelloworldFactory.INSTANCE.createPerson(); + person.setFirstName("Jane"); + person.setLastName("Doe"); + party.getPeople().add(person); +%> +<%= helloWorld.getGreetings(party) %> + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..6f241cc90c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-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-20080910/samples/helloworld-ws-sdo-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..9a4b963cb6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,41 @@ + + + + + + + org.apache.tuscany.sca + sample-helloworld-ws-sdo-webapp + 1.4-SNAPSHOT + war + + + + + org.apache.geronimo.configs + sharedlib + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..257e65aad4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,46 @@ + + + + + + + Apache Tuscany Hello World Web Service SDO Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + tuscany + /services/* + + + + HelloWorld.jsp + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/README new file mode 100644 index 0000000000..be947b1923 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/README @@ -0,0 +1,214 @@ +Hello World Web Service References using SDO Sample +=================================================== +This sample demonstrates an SCA reference that uses a web service binding which works with SDO. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +To run this sample +------------------ +This sample is dependent on helloworld-ws-service. Open a command prompt to start +the service. If you are running ant do the following: + +cd helloworld-ws-service +ant run + +if you don't have ant, issue one of the following commands for windows or *nix: + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-helloworld-ws-service.jar helloworld.HelloWorldServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-service.jar helloworld.HelloWorldServer + +You should see the following output: + +Buildfile: build.xml + +run-server: + [java] log4j:WARN No appenders could be found for logger (org.apache.axiom. +om.util.StAXUtils). + [java] log4j:WARN Please initialize the log4j system properly. + [java] Aug 24, 2007 11:17:33 AM org.apache.catalina.core.StandardEngine sta +rt + [java] INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 + [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.ContextConfig d +efaultWebConfig + [java] INFO: No default web.xml + [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory + register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0. +xsd + [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory + register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt +aglibrary_1_1.dtd + [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory + register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt +aglibrary_1_2.dtd + [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory + register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt +aglibrary_2_0.xsd + [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory + register + [java] WARNING: Could not get url for /javax/servlet/resources/j2ee_web_ser +vices_1_1.xsd + [java] Aug 24, 2007 11:17:34 AM org.apache.coyote.http11.Http11Protocol ini +t + [java] INFO: Initializing Coyote HTTP/1.1 on http-8085 + [java] Aug 24, 2007 11:17:34 AM org.apache.coyote.http11.Http11Protocol sta +rt + [java] INFO: Starting Coyote HTTP/1.1 on http-8085 + [java] Aug 24, 2007 11:17:34 AM org.apache.tuscany.sca.http.tomcat.TomcatSe +rver addServletMapping + [java] INFO: Added Servlet mapping: http://localhost:8085/HelloWorldService + + [java] HelloWorld server started (press enter to shutdown) + +The server is now ready. + + +Now, open another command window to run the client. + +cd helloworld-ws-sdo +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-helloworld-ws-sdo.jar helloworld.HelloWorldClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-sdo.jar helloworl.HelloWorldClient + +You should be able to see the following result: + +Buildfile: build.xml + +run: + [java] log4j:WARN No appenders could be found for logger (org.apache.axiom. +om.util.StAXUtils). + [java] log4j:WARN Please initialize the log4j system properly. + [java] Injected helloWorldService + [java] Called getGreetings + [java] Hello David Haney + +BUILD SUCCESSFUL +Total time: 9 seconds + + +Sample Overview +--------------- +The sample provides a single component that is wired to a reference with a +web service binding. The binding refers to WSDL that identifies the service +exposed by the helloworld-ws-service sample. + +helloworld-ws-sdo/ + src/ + main/ + java/ + helloworld/ + HelloWorldService.java - interface description for + HelloWorldServiceComponent + HelloWorldServiceComponent.java - component implementation + HelloWorldClient.java - starts the SCA Runtime and + deploys the helloworldwsclient + .composite. It then calls the + HelloWorldServiceComponent + resources/ + wsdl + helloworld.wsdl - the service description that the + SCA reference uses to bind to service. + + test/ + java/ + helloworld/ + HelloWorldClientTestCase.java - JUnit test case + helloworld-ws-sdo.png - a pictorial representation of the + sample .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- +You can build and run the sample with the binary distribution using Ant. +Make sure that you have started helloworld-ws-service which this sample is dependent on +in a separate command window. You can either follow the instruction at the begining of this +sample file or if you want to build and run the service, follow the README under helloworld-ws-service. + +Now, let's build and run helloworld-ws-sdo sample: + +cd helloworld-ws-sdo +ant +ant run + +You should see the following output from the run target. + +run: + [java] log4j:WARN No appenders could be found for logger (org.apache.axiom. +om.util.StAXUtils). + [java] log4j:WARN Please initialize the log4j system properly. + [java] Injected helloWorldService + [java] Called getGreetings + [java] Hello World + +Building And Running The Sample Using Maven +------------------------------------------- +You can build and run the sample with either the binary or source distributions using Maven. Please note that you do not need to start helloworld-ws-service in this case since Maven does this for you. + +cd helloworld-ws-sdo +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running helloworld.HelloWorldClientTestCase +log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAX +Utils). +log4j:WARN Please initialize the log4j system properly. +log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAX +Utils). +log4j:WARN Please initialize the log4j system properly. +Aug 23, 2007 2:27:32 PM org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.ContextConfig defaultWebConf +ig +INFO: No default web.xml +Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +1.dtd +Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +2.dtd +Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +Aug 23, 2007 2:27:32 PM org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8085 +Aug 23, 2007 2:27:32 PM org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8085 +Aug 23, 2007 2:27:32 PM org.apache.tuscany.sca.http.tomcat.TomcatServer addServl +etMapping +INFO: Added Servlet mapping: http://localhost:8085/HelloWorldService +Injected helloWorldService +Called getGreetings +Aug 23, 2007 2:27:34 PM org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8085 +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.502 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/build.xml new file mode 100644 index 0000000000..401315d424 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/build.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/helloworld-ws-sdo.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/helloworld-ws-sdo/helloworld-ws-sdo.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/helloworld-ws-sdo.svg b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/helloworld-ws-sdo/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/pom.xml new file mode 100644 index 0000000000..58dc56828f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/pom.xml @@ -0,0 +1,139 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-ws-sdo + Apache Tuscany SCA HelloWorld Web Service SDO Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sdo + tuscany-sdo-lib + 1.1.1 + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.1.1 + + + org.apache.tuscany.sca + tuscany-databinding-sdo + 1.4-SNAPSHOT + compile + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.4-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.1.1 + + + 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-20080910/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..367c5b4a12 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * The interface for the helloworld service + */ +@Remotable +public interface HelloWorldService { + public String getGreetings(Name name); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/helloworld-ws-sdo/src/main/resources/helloworldws.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/resources/helloworldws.composite new file mode 100644 index 0000000000..c255df2897 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/resources/helloworldws.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite new file mode 100644 index 0000000000..d4fba548d5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/main/resources/logging.properties b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/helloworld-ws-sdo/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/helloworld-ws-sdo/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldClientTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldTestServer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/helloworld-ws-service-jms/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/README new file mode 100644 index 0000000000..26272b1d91 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/README @@ -0,0 +1,119 @@ +Hello World SOAP/JMS Service Sample +=================================== +This sample demonstrates an SCA service that uses a web service binding using +a SOAP/JMS protocol + +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-jms.jar helloworld.HelloWorldServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-service-jms.jar helloworld.HelloWorldServer + +Now the server is started you can use the helloworld-ws-reference-jms 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-jms/ + src/ + main/ + java/ + helloworld/ + HelloWorldService.java - interface description for + HelloWorldServiceComponent + HelloWorldImpl.java - component implementation + HelloWorldServer.java - starts the SCA Runtime and + deploys the helloworldwsjms + .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 + helloworldwsjms.composite - the SCA assembly for this sample + helloworldwsjmspolicy.composite - shows how the protocol can be + selected using policy. Not run + by the sample + test/ + java/ + helloworld/ + HelloWorldJMSServerTestCase.java- JUnit test case + HelloWorldJMSPolicyServerTestCase.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-jms +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-jms sample. Take a look at +the README in that sample and you will see you need the following commands + +cd helloworld-ws-reference-jms +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-jms sample as Maven includes a simple ping test to make sure that the +service is available + +cd helloworld-ws-service-jms +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running helloworld.HelloWorldJmsPolicyServerTestCase +08-Jan-2008 10:41:17 org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceProvide +r start +INFO: Axis2 JMS URL=jms:/HelloWorldServiceComponent?java.naming.factory.initial= +org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url= +tcp://localhost:61619&transport.jms.ConnectionFactoryJNDIName=QueueConnectionFac +tory +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.984 sec +Running helloworld.HelloWorldJmsServerTestCase +08-Jan-2008 10:41:22 org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceProvide +r start +INFO: Axis2 JMS URL=jms:/queue.sample?transport.jms.ConnectionFactoryJNDIName=Qu +eueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.Active +MQInitialContextFactory&java.naming.provider.url=tcp://localhost:61619 +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.266 sec + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/build.xml new file mode 100644 index 0000000000..330de7f7e5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/helloworld-ws-service.png b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/helloworld-ws-service.png new file mode 100644 index 0000000000..eab29d0bcd Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/helloworld-ws-service.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/helloworld-ws-service.svg b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/helloworld-ws-service.svg new file mode 100644 index 0000000000..8d2ae98c82 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/helloworld-ws-service.svg @@ -0,0 +1,150 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldws + + HelloWorldServiceComponent + + HelloWorldWebService + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/pom.xml new file mode 100644 index 0000000000..d3e376bd3d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/pom.xml @@ -0,0 +1,87 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-ws-service-jms + Apache Tuscany SCA HelloWorld Web Service JMS Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.4-SNAPSHOT + compile + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + compile + + + + org.apache.activemq + activemq-core + 4.1.1 + compile + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..4cdcc1fd0b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/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-20080910/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldServer.java new file mode 100644 index 0000000000..5454487ff6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldServer.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import java.io.IOException; + +import org.apache.activemq.broker.BrokerService; +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 { + + protected static BrokerService startBroker() throws Exception { + BrokerService jmsBroker = new BrokerService(); + jmsBroker.setPersistent(false); + jmsBroker.setUseJmx(false); + jmsBroker.addConnector("tcp://localhost:61619"); + jmsBroker.start(); + return jmsBroker; + } + + public static void main(String[] args) throws Exception { + + BrokerService broker = startBroker(); + SCADomain scaDomain = SCADomain.newInstance("helloworldwsjms.composite"); + + try { + System.out.println("HelloWorld server started (press enter to shutdown)"); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + scaDomain.close(); + broker.stop(); + System.out.println("HelloWorld server stopped"); + // FIXME: Workaround for http://issues.apache.org/jira/browse/AXIS2-3685 + System.exit(0); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..4b019b21bf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/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; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public String getGreetings(String name); +} + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/definitions.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/definitions.xml new file mode 100644 index 0000000000..8c881ab0bb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/definitions.xml @@ -0,0 +1,66 @@ + + + + + + + The general intent that a transport is available over which SOAP messages flow + + + + + + A JMS transport is required + + + + + + An HTTP transport is required + + + + + + + An HTTPS transport is required + + + + + + + org.apache.activemq.jndi.ActiveMQInitialContextFactory + tcp://localhost:61619 + QueueConnectionFactory + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjms.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjms.composite new file mode 100644 index 0000000000..67079f738e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjms.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjmspolicy.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjmspolicy.composite new file mode 100644 index 0000000000..10faf374f3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjmspolicy.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..3f9e00689e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/test/java/helloworld/HelloWorldJmsPolicyServerTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/test/java/helloworld/HelloWorldJmsPolicyServerTestCase.java new file mode 100644 index 0000000000..34f8605d5d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/test/java/helloworld/HelloWorldJmsPolicyServerTestCase.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 helloworld; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; + +import java.io.IOException; + +import org.apache.activemq.broker.BrokerService; +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 HelloWorldJmsPolicyServerTestCase{ + + private SCADomain scaDomain; + private BrokerService jmsBroker; + + @Before + public void startServer() throws Exception { + startBroker(); + scaDomain = SCADomain.newInstance("helloworldwsjmspolicy.composite"); + } + + protected void startBroker() throws Exception { + jmsBroker = new BrokerService(); + jmsBroker.setPersistent(false); + jmsBroker.setUseJmx(false); + jmsBroker.addConnector("tcp://localhost:61619"); + jmsBroker.start(); + } + + @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(); + if (jmsBroker != null) { + jmsBroker.stop(); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/test/java/helloworld/HelloWorldJmsServerTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/test/java/helloworld/HelloWorldJmsServerTestCase.java new file mode 100644 index 0000000000..03d566cc17 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-jms/src/test/java/helloworld/HelloWorldJmsServerTestCase.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; + +import java.io.IOException; + +import org.apache.activemq.broker.BrokerService; +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 HelloWorldJmsServerTestCase{ + + private SCADomain scaDomain; + private BrokerService jmsBroker; + + @Before + public void startServer() throws Exception { + startBroker(); + scaDomain = SCADomain.newInstance("helloworldwsjms.composite"); + } + + protected void startBroker() throws Exception { + jmsBroker = new BrokerService(); + jmsBroker.setPersistent(false); + jmsBroker.setUseJmx(false); + jmsBroker.addConnector("tcp://localhost:61619"); + jmsBroker.start(); + } + + @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 { + if (scaDomain != null) { + scaDomain.close(); + } + if (jmsBroker != null) { + jmsBroker.stop(); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/README new file mode 100644 index 0000000000..f32eb08b05 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/README @@ -0,0 +1,152 @@ +Hello World Secure Web Service Service Sample +============================================= +This sample demonstrates an SCA service that uses a web service binding that is enabled for simple +authentication using UseridToken and PasswordText + +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-secure.jar helloworld.HelloWorldServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-service-secure.jar helloworld.HelloWorldServer + +Now the server is started you can use the helloworld-ws-reference-secure sample to +exercise it. + +Sample Overview +--------------- +The sample provides a single component that is wired to a service with a +web service binding. The service specifies a policy intent named 'authentication' +which is fulfilled by a suitable policyset that is defined for the SCA Domain. Over +the helloworld-ws-service sample, this sample demonstrate generally the use of policy +intents and policy sets in Tuscany taking the specific instance of a security policy. + +Note : +------ +The policies mentioned and supported are instances of Tuscany specified policies and +not instnaces of WS-Policy. + +helloworld-ws-service-secure/ + 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 + ServerPWCBHandler.java - callback handler to authenticate client userid and password. + The handle(Callback[] callbacks) method of this class typically contains + code for accessing user registries and retrieving passwords + for user identifiers sent by the client and verifying them + against the password sent by the client. For example + here is where one could access LDAP registries to obtain or + compare user identities and passwords. + resources/ + wsdl/ + helloworld.wsdl - the service description that describes + the exposed service + helloworldws.composite - the SCA assembly for this sample + definitions.xml - the SCA Definitions file that contains intents and policysets + defined for the SCA Domain + + helloworld-ws-service-secure.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-secure +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] 14-Jan-2008 14:22:07 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:8085/HelloWorldService + [java] 14-Jan-2008 14:22:07 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:8085/HelloWorldWsPolicyS +ervice + [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. The webservice requires clients to +have security headers that carry userid tonken and password text. + +To stop the server just press enter. + +To exercise the service run up the helloworld-ws-reference-secure sample. Take a look at +the README in that sample and you will see you need the following commands + +cd helloworld-ws-reference-secure +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-secure sample as Maven includes a simple ping test to make sure that the +service is available + +cd helloworld-ws-service-secure +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running helloworld.HelloWorldServerTestCase +14-Jan-2008 14:23:20 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +14-Jan-2008 14:23:20 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +14-Jan-2008 14:23:20 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +14-Jan-2008 14:23:20 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +1.dtd +14-Jan-2008 14:23:20 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +2.dtd +14-Jan-2008 14:23:20 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +14-Jan-2008 14:23:20 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +14-Jan-2008 14:23:21 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:23:21 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:23:21 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8085/HelloWorldService +14-Jan-2008 14:23:21 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8085/HelloWorldWsPolicyService +14-Jan-2008 14:23:21 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: 5.734 sec + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/build.xml new file mode 100644 index 0000000000..29bbae0173 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/helloworld-ws-service-secure.png b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/helloworld-ws-service-secure.png new file mode 100644 index 0000000000..6f7d9dd450 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/helloworld-ws-service-secure.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/helloworld-ws-service-secure.svg b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/helloworld-ws-service-secure.svg new file mode 100644 index 0000000000..53eb552923 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/helloworld-ws-service-secure.svg @@ -0,0 +1,149 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldws + + HelloWorldServiceComponent + + HelloWorldWebService + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/pom.xml new file mode 100644 index 0000000000..b47a865b63 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/pom.xml @@ -0,0 +1,85 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-ws-service-secure + Apache Tuscany SCA HelloWorld Secure Web Service Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.ws.security + wss4j + 1.5.3 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..4cdcc1fd0b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/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-20080910/samples/helloworld-ws-service-secure/src/main/java/helloworld/HelloWorldServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/java/helloworld/HelloWorldServer.java new file mode 100644 index 0000000000..3d43290380 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/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-20080910/samples/helloworld-ws-service-secure/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..4b019b21bf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/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; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public String getGreetings(String name); +} + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/java/helloworld/ServerPWCBHandler.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/java/helloworld/ServerPWCBHandler.java new file mode 100644 index 0000000000..ded02f09d6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/java/helloworld/ServerPWCBHandler.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 javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + */ +public class ServerPWCBHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + System.out.println("*** Calling Server User/Passwd Handler...."); + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + System.out.println("User Id = " + pwcb.getIdentifer()); + System.out.println("Password = " + pwcb.getPassword()); + + if ( pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN ) { + if ( pwcb.getIdentifer().equals("TuscanyWsUser") && + pwcb.getPassword().equals("TuscanyWsUserPasswd") ){ + return; + } else { + throw new UnsupportedCallbackException(pwcb, "Authentication Failed : UserId - Password mismatch"); + } + } else if ( pwcb.getUsage() == WSPasswordCallback.SIGNATURE ) { + pwcb.setPassword("TuscanyWsUserPasswd"); + } + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/definitions.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/definitions.xml new file mode 100644 index 0000000000..10fa7b8652 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/definitions.xml @@ -0,0 +1,113 @@ + + + + + + + + + + UsernameToken + helloworld.ServerPWCBHandler + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TuscanyWsUser + TuscanyWsUser + helloworld.ServerPWCBHandler + + + + JKS + helloworldKeys.jks + TuscanyWsUserPasswd + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/helloworldKeys.jks b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/helloworldKeys.jks new file mode 100644 index 0000000000..0b4f2399f0 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/helloworldKeys.jks differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/helloworldws.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/helloworldws.composite new file mode 100644 index 0000000000..d1e18d7929 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/helloworldws.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..068229be6f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/test/java/helloworld/HelloWorldServerTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/src/test/java/helloworld/HelloWorldServerTestCase.java new file mode 100644 index 0000000000..4a14afcd9d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-secure/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-20080910/samples/helloworld-ws-service-webapp/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/README new file mode 100644 index 0000000000..66040004f8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/README @@ -0,0 +1 @@ +http://localhost:8080/sample-helloworld-ws-service-webapp/SCA/HelloWorldService?wsdl diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/build.xml new file mode 100644 index 0000000000..ff850203b3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/build.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/pom.xml new file mode 100644 index 0000000000..1fbfb2a49d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/pom.xml @@ -0,0 +1,80 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + + sample-helloworld-ws-service-webapp + Apache Tuscany SCA HelloWorld Web Service Sample Webapp + war + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..0de3c70303 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/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-20080910/samples/helloworld-ws-service-webapp/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..268d90e910 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public String getGreetings(String name); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..0b95fbd14f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/webapp/META-INF/sca-deployables/helloworldws.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/webapp/META-INF/sca-deployables/helloworldws.composite new file mode 100644 index 0000000000..114608e4d8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/webapp/META-INF/sca-deployables/helloworldws.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..af87f30703 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,33 @@ + + + + + + + org.apache.tuscany.sca + sample-helloworld-ws-service-webapp + 1.4-SNAPSHOT + war + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..3f3c92fa78 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,45 @@ + + + + + + + Apache Tuscany HelloWorld Web Service Sample + + + org.apache.tuscany.sca.host.webapp.TuscanyContextListener + + + + TuscanyServlet + org.apache.tuscany.sca.host.webapp.TuscanyServlet + + + + TuscanyServlet + /SCA/* + + + + /SCA/HelloWorldComponent/HelloWorldService?wsdl + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/README b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/README new file mode 100644 index 0000000000..44dc7ab4e8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/README @@ -0,0 +1,141 @@ +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] 14-Jan-2008 14:18:47 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:8085/HelloWorldService + [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 +14-Jan-2008 14:19:57 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +14-Jan-2008 14:19:57 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +14-Jan-2008 14:19:57 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +14-Jan-2008 14:19:57 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +1.dtd +14-Jan-2008 14:19:57 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +2.dtd +14-Jan-2008 14:19:57 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +14-Jan-2008 14:19:57 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +14-Jan-2008 14:19:57 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:19:57 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:19:57 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8085/HelloWorldService +14-Jan-2008 14:19:57 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:19:58 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +14-Jan-2008 14:19:58 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +14-Jan-2008 14:19:58 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:19:58 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:19:58 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8085/HelloWorldService +14-Jan-2008 14:19:59 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8085 +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.75 sec + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/build.xml new file mode 100644 index 0000000000..46678febc3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/helloworld-ws-service.png b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/helloworld-ws-service.png new file mode 100644 index 0000000000..eab29d0bcd Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/helloworld-ws-service.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/helloworld-ws-service.svg b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/helloworld-ws-service.svg new file mode 100644 index 0000000000..61cd93ead9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/helloworld-ws-service.svg @@ -0,0 +1,150 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldws + + HelloWorldServiceComponent + + HelloWorldWebService + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/pom.xml new file mode 100644 index 0000000000..ebb56b9a7e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-ws-service + Apache Tuscany SCA HelloWorld Web Service Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + compile + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldServer.java new file mode 100644 index 0000000000..c37bfcda65 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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("META-INF/sca-deployables/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-20080910/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..7245513b2a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/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; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public String getGreetings(String name); +} + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/src/main/resources/META-INF/sca-deployables/helloworldws.composite b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/src/main/resources/META-INF/sca-deployables/helloworldws.composite new file mode 100644 index 0000000000..d767625ae7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/src/main/resources/META-INF/sca-deployables/helloworldws.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/helloworld-ws-service/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/src/test/java/helloworld/HelloWorldServerTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/helloworld-ws-service/src/test/java/helloworld/HelloWorldServerTestCase.java new file mode 100644 index 0000000000..189332be91 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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("META-INF/sca-deployables/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-20080910/samples/implementation-composite/README b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/README new file mode 100644 index 0000000000..27de00e8ef --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-composite/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/build.xml new file mode 100644 index 0000000000..7aa31aab8b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/implementation-composite.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-composite/implementation-composite.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/implementation-composite.svg b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/implementation-composite.svg new file mode 100644 index 0000000000..0e60354aab --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-composite/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/pom.xml new file mode 100644 index 0000000000..229061acb1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/pom.xml @@ -0,0 +1,72 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-implementation-composite + Apache Tuscany SCA Composite 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 + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/src/main/java/composite/CompositeClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-composite/src/main/java/composite/Source.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-composite/src/main/java/composite/SourceCallback.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-composite/src/main/java/composite/SourceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-composite/src/main/java/composite/Target.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-composite/src/main/java/composite/TargetImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-composite/src/main/resources/InnerComposite.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-composite/src/main/resources/InnerComposite.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/src/main/resources/InnerComposite2.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-composite/src/main/resources/InnerComposite2.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/src/main/resources/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-composite/src/main/resources/OuterComposite.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-composite/src/main/resources/OuterComposite.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-composite/src/test/java/composite/CompositeTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-crud-extension/README b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/README new file mode 100644 index 0000000000..5e8190648f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-crud-extension/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/build.xml new file mode 100644 index 0000000000..88d308e6fc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/build.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/pom.xml new file mode 100644 index 0000000000..c11953f0ac --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/pom.xml @@ -0,0 +1,77 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-implementation-crud-extension + Apache Tuscany SCA CRUD Implementation Extension Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-assembly + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-java-xml + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/CRUD.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementation.java b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementation.java new file mode 100644 index 0000000000..49be844f93 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementation.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 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-20080910/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementationFactory.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-crud-extension/src/main/java/crud/backend/ResourceManager.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationFactoryImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationFactoryImpl.java new file mode 100644 index 0000000000..2f1e5fcba8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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 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-20080910/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationInvoker.java b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationInvoker.java new file mode 100644 index 0000000000..b212ee3c9b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationInvoker.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package 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 an invoker for CRUD component implementations. + * + * The invoker is responsible for handling invocations of a business operation. + * Input business data is passed to the invoke method in a Message object. + * The invoke method is responsible for handling the invocation and returning a Message with + * the output business data. + * + * In this example we are simply delegating the CRUD operation invocations to the + * corresponding methods on our fake resource manager class. + * + * More sophisticated invokers can delegate the invocation to an implementation artifact directly + * (for example a Java class using reflection as in the implementation-pojo sample) or call a runtime + * engine like a BPEL engine or an XQuery engine for example (this is what the Tuscany + * implementation-bpel and implementation-xquery extensions do). + */ +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-20080910/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProvider.java b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProvider.java new file mode 100644 index 0000000000..8f11f9d910 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProvider.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package 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; + + +/** + * An implementation provider for sample CRUD implementations. + * + * The implementation provider is responsible for handling the lifecycle of a component + * implementation and creating operation invokers for the service operations provided + * by the implementation. + * + * The start() and stop() methods are called when a component is started + * and stopped. + * + * The createInvoker method is called for each operation provided by the component + * implementation. The implementation provider can create an invoker and initialize it + * at that time to minimize the amount of work to be performed on each invocation. + */ +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 boolean supportsOneWayInvocation() { + return false; + } + + 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-20080910/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProviderFactory.java b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProviderFactory.java new file mode 100644 index 0000000000..4566cb7155 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProviderFactory.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 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; + + +/** + * A factory for CRUD implementation providers. + * + * The factory is called to create an implementation provider for each component using + * the CRUD implementation. + */ +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-20080910/samples/implementation-crud-extension/src/main/resources/META-INF/services/crud.CRUDImplementationFactory b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/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-20080910/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-20080910/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-20080910/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema new file mode 100644 index 0000000000..527c626418 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# URI of the XML schema to be used for validation +sample-implementation-crud.xsd diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-crud-extension/src/main/resources/sample-implementation-crud.xsd b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/resources/sample-implementation-crud.xsd new file mode 100644 index 0000000000..447e31bf93 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/main/resources/sample-implementation-crud.xsd @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/test/java/crud/CRUDTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/test/java/crud/CRUDTestCase.java new file mode 100644 index 0000000000..0bb5cfc361 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud-extension/src/test/java/crud/CRUDTestCase.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 crud; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import crud.CRUD; + +/** + * Tests the CRUD implementation extension. + */ +public class CRUDTestCase extends TestCase { + + private SCADomain scaDomain; + private CRUD crudService; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("crud.composite"); + crudService = scaDomain.getService(CRUD.class, "CRUDServiceComponent"); + } + + @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-20080910/samples/implementation-crud-extension/src/test/resources/crud.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-crud-extension/src/test/resources/crud.composite @@ -0,0 +1,30 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/README b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/README new file mode 100644 index 0000000000..50da631c04 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-crud/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/build.xml new file mode 100644 index 0000000000..10b26b5a94 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/build.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/implementation-crud.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-crud/implementation-crud.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/implementation-crud.svg b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/implementation-crud.svg new file mode 100644 index 0000000000..dbb37be208 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-crud/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/pom.xml new file mode 100644 index 0000000000..3cc75a6f7d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/pom.xml @@ -0,0 +1,64 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-implementation-crud + Apache Tuscany SCA CRUD Implementation Extension Sample Client + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + sample-implementation-crud-extension + 1.4-SNAPSHOT + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/src/main/java/crud/client/CRUDClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/src/main/java/crud/client/CRUDClient.java new file mode 100644 index 0000000000..ea87cb3001 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/src/main/java/crud/client/CRUDClient.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 crud.client; + + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import crud.CRUD; + +/** + * A sample client that shows how to create an SCA domain, get a service, and + * invoke service methods of a CRUD component. + * + * The CRUD component uses an implementation extension + * from module implementation-crud-extension. + * + * @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); + System.out.println("Result from delete: " + result); + + scaDomain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/src/main/resources/crud.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-crud/src/main/resources/crud.composite @@ -0,0 +1,30 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/src/test/java/crud/client/CRUDTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/src/test/java/crud/client/CRUDTestCase.java new file mode 100644 index 0000000000..7e0476a8b1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-crud/src/test/java/crud/client/CRUDTestCase.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 crud.client; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import crud.CRUD; + + +/** + * Tests the sample crud composite. + */ +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-20080910/samples/implementation-notification/README b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/README new file mode 100644 index 0000000000..5b59358080 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/README @@ -0,0 +1,93 @@ +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: + +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-implementation-notification.jar notification.TrafficAdvisoryClient + +OR you can also use Maven to test: + +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 Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant as +follows + +cd implementation-notification +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] Consumer [Consumer1] received report: Nothing to report today + [java] Consumer [Consumer2] received report: Nothing to report today + +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-20080910/samples/implementation-notification/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/build.xml new file mode 100644 index 0000000000..110c7b84c1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/implementation-notification.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-notification/implementation-notification.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/pom.xml new file mode 100644 index 0000000000..584e3cc4c7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/pom.xml @@ -0,0 +1,75 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-implementation-notification + Apache Tuscany SCA Notification Implementation Sample + 1.4-SNAPSHOT + A sample illustrating use of implementation.notification + + + + org.apache.tuscany.sca + tuscany-implementation-notification + 1.4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-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-20080910/samples/implementation-notification/src/main/java/notification/TestCaseProducer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-notification/src/main/java/notification/TrafficAdvisory.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryClient.java new file mode 100644 index 0000000000..da32bab58d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryClient.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 notification; + +import notification.TestCaseProducer; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class TrafficAdvisoryClient { + + public static void main(String[] args) throws Exception { + try { + SCADomain domain = SCADomain.newInstance("TrafficAdvisoryNotification.composite"); + TestCaseProducer testCaseProducer = domain.getService(TestCaseProducer.class, "TrafficAdvisoryProducer"); + + testCaseProducer.produceTrafficNotification("Nothing to report today"); + + domain.close(); + } catch(Throwable e) { + e.printStackTrace(); + if (e instanceof Exception) { + throw (Exception)e; + } + else { + throw new Exception(e); + } + } + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryConsumer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryProducer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.componentType b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.componentType new file mode 100644 index 0000000000..873e200613 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.componentType @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.composite b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.composite new file mode 100644 index 0000000000..bbf2281352 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + Consumer1 + + + + + Consumer2 + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/test/java/notification/TrafficAdvisoryTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + Consumer1 + + + + + Consumer2 + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/README b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/README new file mode 100644 index 0000000000..3b201779e1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-pojo-extension/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/build.xml new file mode 100644 index 0000000000..78bae79859 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/build.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/pom.xml new file mode 100644 index 0000000000..d7bb120e93 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/pom.xml @@ -0,0 +1,77 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-implementation-pojo-extension + Apache Tuscany SCA POJO Implementation Extension Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-java-xml + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java new file mode 100644 index 0000000000..f2d6871039 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.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 java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sca.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-20080910/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java new file mode 100644 index 0000000000..44a2cc0aa8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java @@ -0,0 +1,174 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package 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.assembly.xml.PolicyAttachPointProcessor; +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 org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.policy.PolicyFactory; + +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; + private PolicyFactory policyFactory; + private PolicyAttachPointProcessor policyProcessor; + + public POJOImplementationProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + + // 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); + policyFactory = modelFactories.getFactory(PolicyFactory.class); + pojoImplementationFactory = modelFactories.getFactory(POJOImplementationFactory.class); + policyProcessor = new PolicyAttachPointProcessor(policyFactory); + } + + 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 + POJOImplementation implementation = pojoImplementationFactory.createPOJOImplementation(); + + // Read policies + policyProcessor.readPolicies(implementation, reader); + + // Read the POJO class attribute. + String className = reader.getAttributeValue(null, "class"); + 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 implementation, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { + + // Write element + policyProcessor.writePolicyPrefixes(implementation, writer); + writer.writeStartElement(IMPLEMENTATION_POJO.getNamespaceURI(), IMPLEMENTATION_POJO.getLocalPart()); + policyProcessor.writePolicyAttributes(implementation, writer); + + if (implementation.getPOJOName() != null) { + writer.writeAttribute("class", implementation.getPOJOName()); + } + + writer.writeEndElement(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java new file mode 100644 index 0000000000..87333c61f6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.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 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; + +/** + * Implements an invoker for POJO component implementations. + * + * The invoker is responsible for handling invocations of a business operation. + * Input business data is passed to the invoke method in a Message object. + * The invoke method is responsible for handling the invocation and returning a Message with + * the output business data. + * + * In this example we are simply delegating the operation invocations to the + * corresponding methods on the POJO implementation class using Java reflection. + * + * Depending on the type of implementation being handled, more sophisticated invokers can + * use other techniques to delegate the invocation to the implementation artifact directly, call a + * runtime engine like a BPEL engine or an XQuery engine (this is what the Tuscany + * implementation-bpel and implementation-xquery extensions do) or just completely handle the + * invocation in the invoker itself if the implementation has a fixed behavior for example. + */ +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-20080910/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java new file mode 100644 index 0000000000..73a0d22493 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.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 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; + +/** + * An implementation provider for sample CRUD implementations. + * + * The implementation provider is responsible for handling the lifecycle of a component + * implementation and creating operation invokers for the service operations provided + * by the implementation. + * + * The start() and stop() methods are called when a component is started + * and stopped. In this example we are using that opportunity to call init and destroy methods + * on the POJO instance if these methods exist. + * + * The createInvoker method is called for each operation provided by the component + * implementation. The implementation provider can create an invoker and initialize it + * at that time to minimize the amount of work to be performed on each invocation. + * + * For example here we are looking up the Java method corresponding to the service operation + * at passing it to the invoker constructor. This way the invoker won't have to lookup the Java + * method on each invocation. + */ +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 boolean supportsOneWayInvocation() { + return false; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java new file mode 100644 index 0000000000..22f2be09e9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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; + +/** + * A factory for POJO implementation providers. + */ +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-20080910/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-20080910/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-20080910/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-20080910/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema new file mode 100644 index 0000000000..64dd230a15 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# URI of the XML schema to be used for validation +sample-implementation-pojo.xsd diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-pojo-extension/src/main/resources/sample-implementation-pojo.xsd b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/resources/sample-implementation-pojo.xsd new file mode 100644 index 0000000000..c9d170770b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/main/resources/sample-implementation-pojo.xsd @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java new file mode 100644 index 0000000000..d8b5f41adc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Tests the POJO implementation extension. + */ +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-20080910/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/pom.xml new file mode 100644 index 0000000000..e2551fd7dc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-loanapplication + Apache Tuscany SCA Loan Application Conversation Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/src/main/java/loanapplication/LoanApplication.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/loanapplication/src/main/java/loanapplication/LoanApplicationClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/loanapplication/src/main/java/loanapplication/LoanClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/loanapplication/src/main/java/loanapplication/LoanClientImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/loanapplication/src/main/java/loanapplication/LoanService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/loanapplication/src/main/java/loanapplication/LoanServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/loanapplication/src/main/resources/loanapplication.composite b/sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/src/main/resources/loanapplication.composite new file mode 100644 index 0000000000..3aa8d030b7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/src/main/resources/loanapplication.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/loanapplication/src/test/java/loanapplication/LoanApplicationTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/README b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/README new file mode 100644 index 0000000000..11fecf2ae8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/README @@ -0,0 +1,161 @@ +osgi-supplychain Sample +======================= + +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. + +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 + +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 + + +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. The Customer +and Shipper components are implemented as OSGi bundles which use +implementation.osgi, while the Retailer and Warehouse components are +implemented using implementation.java. + + +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 + + + build.xml - the Ant build file + pom.xml - the Maven build file + +Understanding OSGI implementation files +--------------------------------------- +Some of the files introduced by OSGI implementation are explained below. + +OSG files related to customer. java are: +OSGiCustomerComponentImpl.java: OSGi Declarative Services Implementation of the SCA Customer component. +OSGiCustomerImpl.java: OSGi Procedural Services Implementation of the SCA Customer component. + +You notice the same pattern for shipper.java, retailer.java, SupplyChainClient.java. + +The rest of OSGI related files are: +OSGiBundleImpl.java: Common code for OSGi Procedural Services Implementation of the SCA components + +resources/osgi/*.mf: Manifest files for OSGi bundles for OSGi procedural services implementation + +resources/osgi/ds/*.m:f Manifest files for OSGi bundles for OSGi declarative services implementation + +resources/osgi/ds/*.xml: OSGi 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.composite: Composite file using OSGi (declarative services) and Java implementation types + +Building And Running The Sample Using Ant +----------------------------------------- +cd osgi-supplychain +ant compile +ant run + +you should see: +Buildfile: build.xml + +run: + [java] Main thread Thread[main,5,main] + [java] Started OSGi bundle with activator OSGiCustomerImpl + [java] Started OSGi bundle with activator OSGiShipperImpl + [java] Main thread sleeping ... + [java] Work thread Thread[pool-1-thread-1,5,main] - Order, submitted, fulfi +lled, shipped + [java] Stop OSGi bundle with activator OSGiShipperImpl + [java] Stop OSGi bundle with activator OSGiCustomerImpl + + +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 osgi-supplychain +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running supplychain.SupplyChainClientTestCase +Started OSGi bundle with activator OSGiCustomerImpl +Started OSGi bundle with activator OSGiShipperImpl +Sleeping ... +Work thread Thread[pool-1-thread-1,5,main] - Order, submitted, fulfilled, shippe +d +Test complete +Stop OSGi bundle with activator OSGiShipperImpl +Stop OSGi bundle with activator OSGiCustomerImpl +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.062 sec + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/build-bundles.xml b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/build-bundles.xml new file mode 100644 index 0000000000..7a31e6016b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/build-bundles.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/build.xml new file mode 100644 index 0000000000..2e103e5a15 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/build.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/osgi-supplychain.png b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/osgi-supplychain.png new file mode 100644 index 0000000000..2bec57ac8a Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/osgi-supplychain.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/osgi-supplychain.svg b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/osgi-supplychain.svg new file mode 100644 index 0000000000..43cb427944 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/osgi-supplychain.svg @@ -0,0 +1,272 @@ + + + + + + + + + + image/svg+xml + + + + + + + + supplychain + + CustomerComponent + + + RetailerComponent + + + WharehouseComponent + + + ShipperComponent + + + + + + OSGi + Java + Java + OSGi + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/pom.xml new file mode 100644 index 0000000000..e2a2e0574e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/pom.xml @@ -0,0 +1,187 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-osgi-supplychain + Apache Tuscany SCA OSGi Supply Chain Sample + + + + + org.apache.felix + org.apache.felix.main + 1.0.4 + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-osgi + 1.4-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-20080910/samples/osgi-supplychain/src/main/java/supplychain/OSGiBundleImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/OSGiBundleImpl.java new file mode 100644 index 0000000000..5f40054ada --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/OSGiBundleImpl.java @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package 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) { + + 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 OSGi bundle with activator " + 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 OSGi bundle with activator " + 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-20080910/samples/osgi-supplychain/src/main/java/supplychain/SupplyChainClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/java/supplychain/customer/Customer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java new file mode 100644 index 0000000000..023d716651 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/customer/JavaCustomerComponentImpl.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 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() { + 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-20080910/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java new file mode 100644 index 0000000000..a1c7fce60a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.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 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() { + 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-20080910/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerImpl.java new file mode 100644 index 0000000000..4647a716c7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerImpl.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.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() { + 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-20080910/samples/osgi-supplychain/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.java new file mode 100644 index 0000000000..d0d29f94f8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.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 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) { + + warehouse.fulfillOrder(order + ", submitted"); + + } + + + + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.java new file mode 100644 index 0000000000..1b7fb15bf1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.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.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) { + + warehouse.fulfillOrder(order + ", submitted"); + + } + + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerImpl.java new file mode 100644 index 0000000000..e97331c06c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerImpl.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.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) { + warehouse.fulfillOrder(order + ", submitted"); + + } + + + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/retailer/Retailer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/java/supplychain/shipper/JavaShipperComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/shipper/JavaShipperComponentImpl.java new file mode 100644 index 0000000000..4206ce7dc8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/shipper/JavaShipperComponentImpl.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.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) { + customer.notifyShipment(order + ", shipped"); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperComponentImpl.java new file mode 100644 index 0000000000..0f88cca213 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperComponentImpl.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 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) { + customer.notifyShipment(order + ", shipped"); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperImpl.java new file mode 100644 index 0000000000..f55a068ede --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperImpl.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 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) { + customer.notifyShipment(order + ", shipped"); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/shipper/Shipper.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/java/supplychain/warehouse/JavaWarehouseComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/warehouse/JavaWarehouseComponentImpl.java new file mode 100644 index 0000000000..72eec76cc2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/warehouse/JavaWarehouseComponentImpl.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.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) { + shipper.processShipment(order + ", fulfilled"); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseComponentImpl.java new file mode 100644 index 0000000000..600f3f0c74 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseComponentImpl.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.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) { + shipper.processShipment(order + ", fulfilled"); + + } + + + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseImpl.java new file mode 100644 index 0000000000..b8bca97bd0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseImpl.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.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) { + shipper.processShipment(order + ", fulfilled"); + + } + + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/java/supplychain/warehouse/Warehouse.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/resources/Customer.componentType b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/resources/DSCustomer.componentType b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/DSCustomer.componentType new file mode 100644 index 0000000000..87a184d968 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/DSCustomer.componentType @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/DSRetailer.componentType b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/DSRetailer.componentType new file mode 100644 index 0000000000..872ab6601a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/DSRetailer.componentType @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/DSShipper.componentType b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/DSShipper.componentType new file mode 100644 index 0000000000..57fcbbc5d1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/DSShipper.componentType @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/DSWarehouse.componentType b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/DSWarehouse.componentType new file mode 100644 index 0000000000..75fa8029f7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/DSWarehouse.componentType @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/Retailer.componentType b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/resources/Shipper.componentType b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/resources/Warehouse.componentType b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/resources/osgi/Customer.mf b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/resources/osgi/Retailer.mf b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/resources/osgi/Shipper.mf b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/resources/osgi/Warehouse.mf b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.mf b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.xml b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.xml new file mode 100644 index 0000000000..5b368afd5b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.xml @@ -0,0 +1,32 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.mf b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.xml b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.xml new file mode 100644 index 0000000000..cae7fdfde2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.xml @@ -0,0 +1,32 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.mf b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.xml b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.xml new file mode 100644 index 0000000000..d894309b71 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.xml @@ -0,0 +1,33 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.mf b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.xml b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.xml new file mode 100644 index 0000000000..fc86a76784 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.xml @@ -0,0 +1,32 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/supplychain.composite b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/supplychain.composite new file mode 100644 index 0000000000..0bbfed9176 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/supplychain.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/supplychain.ds.composite b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/supplychain.ds.composite new file mode 100644 index 0000000000..d1e11168e2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/main/resources/supplychain.ds.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java new file mode 100644 index 0000000000..ff15c0d9a2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/osgi-supplychain/src/test/java/supplychain/SupplyChainClientTestCase.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 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 { + + customer.purchaseGoods(); + + System.out.println("Sleeping ..."); + Thread.sleep(2000); + System.out.println("Test complete"); + + } + + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/README b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/README new file mode 100644 index 0000000000..c66edea985 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/README @@ -0,0 +1,28 @@ +Photo-Gallery Sample +====================================== + +This is a sample store scenario that is used as a getting started guide +for Tuscany SCA. For detailed information, please see: + +http://tuscany.apache.org/getting-started-with-tuscany.html + +or + +http://tuscany.apache.org/getting-started-with-tuscany-using-tuscany-eclipse-plugin.html + + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built using Ant as follows: + +cd store +ant compile + +and then, to run: + +ant run + +Once the store application is running use your browser to visit the following +URL: + +http://localhost:8080/gallery/ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/build.xml new file mode 100644 index 0000000000..652afc3570 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/build.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/photo-gallery.png b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/photo-gallery.png new file mode 100644 index 0000000000..da413edeee Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/photo-gallery.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/photo-gallery.svg b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/photo-gallery.svg new file mode 100644 index 0000000000..74f8ecd36d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/photo-gallery.svg @@ -0,0 +1,304 @@ + + + + + + + + + + image/svg+xml + + + + + + + + store + ufs + + ShoppingCart + + CurrencyConverter + + + + + + + + + + CurrenyCode HTTP JSONRPC Atom + + Catalog + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/pom.xml new file mode 100644 index 0000000000..1c258b47c8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/pom.xml @@ -0,0 +1,148 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../pom.xml + + sample-photo-gallery + Apache Tuscany SCA Getting Started Online Store Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-data-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-widget-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.4-SNAPSHOT + runtime + + + + org.apache.derby + derby + 10.2.1.6 + + + + org.slf4j + slf4j-api + 1.3.0 + + + + org.slf4j + slf4j-log4j12 + 1.3.0 + + + + org.slf4j + jcl104-over-slf4j + 1.3.0 + + + + javax.jcr + jcr + 1.0 + + + + org.apache.jackrabbit + jackrabbit-core + 1.4 + + + + org.apache.jackrabbit + jackrabbit-api + 1.4 + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/launch/LaunchGallery.java b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/launch/LaunchGallery.java new file mode 100644 index 0000000000..1007cd49b0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/launch/LaunchGallery.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 launch; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class LaunchGallery { + public static void main(String[] args) throws Exception { + System.out.println("Starting ..."); + SCADomain scaDomain = SCADomain.newInstance("photo-gallery.composite"); + System.out.println("photo.gallery.composite ready for big business !!!"); + System.in.read(); + System.out.println("Stopping ..."); + scaDomain.close(); + System.out.println(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/launch/LaunchGalleryJCR.java b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/launch/LaunchGalleryJCR.java new file mode 100644 index 0000000000..d07dc63592 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/launch/LaunchGalleryJCR.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 launch; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class LaunchGalleryJCR { + public static void main(String[] args) throws Exception { + System.out.println("Starting ..."); + SCADomain scaDomain = SCADomain.newInstance("photo-gallery-jcr.composite"); + System.out.println("photo.gallery.composite ready for big business !!!"); + System.in.read(); + System.out.println("Stopping ..."); + scaDomain.close(); + System.out.println(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/services/Album.java b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/services/Album.java new file mode 100644 index 0000000000..5257d0e703 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/services/Album.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Album { + + public String[] getPictures(); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/services/AlbumImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/services/AlbumImpl.java new file mode 100644 index 0000000000..dd2b086e29 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/services/AlbumImpl.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import java.io.File; +import java.io.FilenameFilter; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Property; + +public class AlbumImpl implements Album { + private String gallery; + private String album; + private String location; + private List pictures = new ArrayList(); + + @Property + public void setGallery(String gallery) { + this.gallery = gallery; + this.location = null; + } + @Property + public void setAlbum(String album) { + this.album = album; + this.location = null; + } + + protected String getLocation() { + if (location == null) { + location = gallery + "/" + album + "/"; + } + return location; + + } + + @Init + public void init() { + try { + URL albumURL = this.getClass().getClassLoader().getResource(getLocation()); + if(albumURL != null) { + File album = new File(albumURL.toURI()); + if (album.isDirectory() && album.exists()) { + String[] listPictures = album.list(new ImageFilter(".jpg")); + for(String image : listPictures) { + image = getLocation() + image; + pictures.add(image); + } + } + } + } catch (Exception e) { + // FIXME: ignore for now + e.printStackTrace(); + } + } + + public String[] getPictures() { + String[] pictureArray = new String[pictures.size()]; + pictures.toArray(pictureArray); + return pictureArray; + } + + /** + * Inner fileFilter class + */ + private class ImageFilter implements FilenameFilter { + String afn; + ImageFilter(String afn) { this.afn = afn; } + public boolean accept(File dir, String name) { + // Strip path information: + String f = new File(name).getName(); + return f.indexOf(afn) != -1; + } + } ///:~ + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/services/jcr/AlbumImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/services/jcr/AlbumImpl.java new file mode 100644 index 0000000000..ac4e6f52f4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/java/services/jcr/AlbumImpl.java @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services.jcr; + +import java.io.File; +import java.io.FilenameFilter; +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +import javax.jcr.Node; +import javax.jcr.NodeIterator; +import javax.jcr.Repository; +import javax.jcr.Session; +import javax.jcr.SimpleCredentials; + +import org.apache.jackrabbit.core.TransientRepository; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Property; + +import services.Album; + +public class AlbumImpl implements Album { + private String gallery; + private String album; + private String location; + private Repository repository=null; + private Session session=null; + + @Property + public void setGallery(String gallery) { + this.gallery = gallery; + this.location = null; + } + @Property + public void setAlbum(String album) { + this.album = album; + this.location = null; + } + + protected String getLocation() { + if (location == null) { + location = gallery + "/" + album + "/"; + } + return location; + + } + + @Init + public void init() { + try { + URL albumURL = this.getClass().getClassLoader().getResource(getLocation()); + if(albumURL != null) { + repository = new TransientRepository(); + session = repository.login( + new SimpleCredentials("username", "password".toCharArray())); + try { + File album = new File(albumURL.toURI()); + if (album.isDirectory() && album.exists()) { + String[] listPictures = album.list(new ImageFilter(".jpg")); + for(String image : listPictures) { + Node root=session.getRootNode(); + Node picNode=root.addNode(image); + InputStream inFile = getClass().getClassLoader().getResourceAsStream(getLocation()+image); + picNode.setProperty("image", inFile ); + picNode.setProperty("name", image); + picNode.setProperty("location", getLocation()+image); + //image = getLocation() + image; + //pictures.add(image); + } + } + + session.save(); + }catch (Exception e){ + // FIXME: ignore for now + e.printStackTrace(); + } + } + } catch (Exception e) { + // FIXME: ignore for now + e.printStackTrace(); + } + } + + public String[] getPictures() { + List pictures = new ArrayList(); + + try{ + Node root=session.getRootNode(); + NodeIterator nodes = root.getNodes(); + + while(nodes.hasNext()){ + Node node=nodes.nextNode(); + if(node.getPath().equals("/jcr:system")) continue; + + pictures.add(node.getProperty("location").getString()); + //System.out.println(node.getProperty("name").getString()); + //System.out.println(node.getPath()); + } + }catch (Exception e) { + // FIXME: ignore for now + e.printStackTrace(); + } + + String[] pictureArray = new String[pictures.size()]; + pictures.toArray(pictureArray); + removeNodes(); + return pictureArray; + } + + + public void removeNodes(){ + try{ + Node root=session.getRootNode(); + NodeIterator nodes = root.getNodes(); + while(nodes.hasNext()){ + Node node=nodes.nextNode(); + if(node.getPath().equals("/jcr:system")) continue; + else node.remove(); + } + session.save(); + }catch (Exception e) { + // FIXME: ignore for now + e.printStackTrace(); + } + + } + /** + * Inner fileFilter class + */ + private class ImageFilter implements FilenameFilter { + String afn; + ImageFilter(String afn) { this.afn = afn; } + public boolean accept(File dir, String name) { + // Strip path information: + String f = new File(name).getName(); + return f.indexOf(afn) != -1; + } + } ///:~ + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery.html b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery.html new file mode 100644 index 0000000000..f6566e88ec --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery.html @@ -0,0 +1,135 @@ + + + +Photo Gallery + + + + + + + + + +
+

Apache Tuscany Photo Gallery

+
+
+ + +
+ + + + + +
+ + + + + + + + +
+
+ + + + + +
+ +
+ +
+ + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00368.jpg b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00368.jpg new file mode 100644 index 0000000000..9437b321e2 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00368.jpg differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00369.jpg b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00369.jpg new file mode 100644 index 0000000000..07f37ec505 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00369.jpg differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00370.jpg b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00370.jpg new file mode 100644 index 0000000000..2193784271 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00370.jpg differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00371.jpg b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00371.jpg new file mode 100644 index 0000000000..1532ee2c1b Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00371.jpg differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00373.jpg b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00373.jpg new file mode 100644 index 0000000000..17ffd73aec Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00373.jpg differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00375.jpg b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00375.jpg new file mode 100644 index 0000000000..19e9ec37df Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00375.jpg differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00376.jpg b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00376.jpg new file mode 100644 index 0000000000..022416dbce Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00376.jpg differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00377.jpg b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00377.jpg new file mode 100644 index 0000000000..c78a974714 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00377.jpg differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00378.jpg b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00378.jpg new file mode 100644 index 0000000000..a98070925a Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00378.jpg differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00379.jpg b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00379.jpg new file mode 100644 index 0000000000..dc83889116 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00379.jpg differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00380.jpg b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00380.jpg new file mode 100644 index 0000000000..0e33548135 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/gallery/boston/dsc00380.jpg differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/index.gif b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/index.gif new file mode 100755 index 0000000000..7599ac7686 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/index.gif differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/index_on.gif b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/index_on.gif new file mode 100755 index 0000000000..153e9879d6 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/index_on.gif differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/next.gif b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/next.gif new file mode 100755 index 0000000000..002eaf6951 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/next.gif differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/next_disabled.gif b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/next_disabled.gif new file mode 100755 index 0000000000..38b1298453 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/next_disabled.gif differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/next_on.gif b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/next_on.gif new file mode 100755 index 0000000000..4e5bb3e7ef Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/next_on.gif differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/photo-gallery-jcr.composite b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/photo-gallery-jcr.composite new file mode 100644 index 0000000000..23190de555 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/photo-gallery-jcr.composite @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + gallery + boston + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/photo-gallery.composite b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/photo-gallery.composite new file mode 100644 index 0000000000..0bb3c4b4db --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/photo-gallery.composite @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + gallery + boston + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/prev.gif b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/prev.gif new file mode 100755 index 0000000000..4eea10f1dc Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/prev.gif differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/prev_disabled.gif b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/prev_disabled.gif new file mode 100755 index 0000000000..7e35f07076 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/prev_disabled.gif differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/prev_on.gif b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/prev_on.gif new file mode 100755 index 0000000000..3ef9a776bb Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/prev_on.gif differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/show_slide.gif b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/show_slide.gif new file mode 100644 index 0000000000..a5b6a15c2b Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/show_slide.gif differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/space.gif b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/space.gif new file mode 100644 index 0000000000..170fe82b65 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/space.gif differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/styles.css b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/styles.css new file mode 100755 index 0000000000..d23d949858 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/photo-gallery/src/main/resources/styles.css @@ -0,0 +1,121 @@ +body { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 12px; + color: #888888; + background-color: #000000; + margin-top: 0px; +} + +html { + scrollbar-face-color:#444444; + scrollbar-highlight-color:#000000; + scrollbar-3dlight-color:#000000; + scrollbar-darkshadow-color:#000000; + scrollbar-shadow-color:#000000; + scrollbar-arrow-color:#888888; + scrollbar-track-color:#000000; +} + +a:link { + text-decoration: none; + color: #AAAAAA; +} + +a:visited { + text-decoration: none; + color: #AAAAAA; +} + +a:hover { + text-decoration: none; + color: #FFFFFF; +} + +.current { + font-weight: bold; + color: #AAAAAA; + background-color: #666666; +} + +.cthumb { + background-color: #666666; + border: 0px; border-width: 0px; +} + +.thumb { + background-color: #333333; + border: 0px; border-width: 0px; +} + +.image { margin: 0px; border-width: 1px; border: 1px solid;} +a:link .image { border-color: #aaaaaa; color: #aaaaaa;} +a:visited .image { border-color: #666666; color: #666666;} +a:hover .image { border-color: #ffffff; color: #ffffff;} + +.slideImage { border-width: 0px; border: 0px solid; border-color: #ffffff;} +a:link .slideImage { border-color: #ffffff;} +a:visited .slideImage { border-color: #ffffff;} + +.title { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + font-weight: bold; + color: #000000; +} + +.title a:link { + text-decoration: none; + color: #000000; +} + +.title a:visited { + text-decoration: none; + color: #000000; +} + +.title a:hover { + text-decoration: none; + color: #ffffff; +} + +.infotable { + border: 1px solid #444444; + border-collapse: collapse; +} + +.infotable td { + border: 1px solid #444444; +} + +.infotable table td { + border: 0px; +} + +.dirname { + font-size: 12px; + font-weight: bold; + color: #AAAAAA; +} + +.comment { + color: #CCCCCC; + font-weight: bold; + font-size: 12px; +} + +.smalltxt { + color: #888888; + font-size: 11px; +} + +.xsmalltxt { + color: #888888; + font-size: 9px; +} + +.newlabel { + font-size: 8px; + font-weight: bold; + color: #EEEEEE; + background-color: #558800; +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/pom.xml new file mode 100644 index 0000000000..5176eab59f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/pom.xml @@ -0,0 +1,110 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../pom.xml + + tuscany-samples + pom + Apache Tuscany SCA Samples + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + default + + true + + + binding-echo + binding-echo-extension + binding-notification-broker + binding-notification-consumer + binding-notification-producer + calculator + calculator-lean + calculator-distributed + calculator-implementation-policies + calculator-rmi-reference + calculator-rmi-service + calculator-script + calculator-webapp + calculator-ws-secure-webapp + calculator-ws-webapp + callback-ws-client + callback-ws-service + chat-webapp + customer-dojo + databinding-echo + + domain-management + feed-aggregator + feed-aggregator-webapp + helloworld-bpel + helloworld-dojo-webapp + helloworld-jms-webapp + helloworld-jsonrpc-webapp + helloworld-reference-jms + helloworld-service-jms + helloworld-ws-service + helloworld-ws-service-jms + helloworld-ws-service-secure + helloworld-ws-reference + helloworld-ws-reference-lean + helloworld-ws-reference-jms + helloworld-ws-reference-secure + helloworld-ws-sdo + helloworld-ws-sdo-webapp + implementation-composite + implementation-crud + implementation-crud-extension + implementation-notification + implementation-pojo-extension + loanapplication + osgi-supplychain + photo-gallery + quote-xquery + simple-bigbank + simple-bigbank-spring + spring-bigbank-checkaccount + spring-bigbank-calculator + spring-bigbank-stockquote + simple-callback + simple-callback-ws + store + store-distributed + supplychain + web-resource + zipcode-jaxws + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/README b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/README new file mode 100644 index 0000000000..cf8a4609a6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/README @@ -0,0 +1,450 @@ +Quote Xquery Sample +=================== + + This sample covers the most important integration scenarios for the xquery + implementation type and its corresponding saxon data bindings. + +If you just want to run it to see what happens open two command prompts (one for the server +and the other for the client), navigate to this sample directory and do: + +Command Prompt 1: +ant +ant run-server + +Command Prompt 2: +ant run + +OR if you don't have ant, on Windows do + +In the directory samples\quote-xquery use the JDK 1.5 java command to run the class xquery.quote.XQueryQuoteClient + +Linux: java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-quote-xquery.jar xquery.quote.XQueryQuoteServer +Linux: java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-quote-xquery.jar xquery.quote.XQueryQuoteClient + +Windows: java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-quote-xquery.jar xquery.quote.XQueryQuoteServer +Windows: java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-quote-xquery.jar xquery.quote.XQueryQuoteClient + +Results +---------- +The sample when run should simply display on the standard output some startup messages followed by: + +The compilation: + +Buildfile: build.xml + +init: + +generate-sdo: + [java] >> Generating code + [java] >> Generating packages + [java] >> Generating package QuotePackageImpl + [java] >> Generating Java interface org.example.quote.QuoteFactory + [java] >> Generating /TargetProject/org/example/quote/QuoteFactory.java + [java] >> Examining old /TargetProject/org/example/quote/QuoteFactory.java + [java] >> Generating Java class org.example.quote.impl.QuoteFactoryImpl + [java] >> Generating /TargetProject/org/example/quote/impl/QuoteFactoryImpl.java + [java] >> Examining old /TargetProject/org/example/quote/impl/QuoteFactoryImpl.java + [java] >> Generating Quote + [java] >> Generating Java interface org.example.quote.Quote + [java] >> Generating /TargetProject/org/example/quote/Quote.java + [java] >> Examining old /TargetProject/org/example/quote/Quote.java + [java] >> Generating Java class org.example.quote.impl.QuoteImpl + [java] >> Generating /TargetProject/org/example/quote/impl/QuoteImpl.java + [java] >> Examining old /TargetProject/org/example/quote/impl/QuoteImpl.java + [java] >> Generating Response + [java] >> Generating Java interface org.example.quote.QuoteResponse + [java] >> Generating /TargetProject/org/example/quote/QuoteResponse.java + [java] >> Examining old /TargetProject/org/example/quote/QuoteResponse.java + [java] >> Generating Java class org.example.quote.impl.QuoteResponseImpl + [java] >> Generating /TargetProject/org/example/quote/impl/QuoteResponseImpl.java + [java] >> Examining old /TargetProject/org/example/quote/impl/QuoteResponseImpl.java + [java] >> Generating code + [java] >> Generating packages + [java] >> Generating package AvailPackageImpl + [java] >> Generating Java interface org.example.avail.AvailFactory + [java] >> Generating /TargetProject/org/example/avail/AvailFactory.java + [java] >> Examining old /TargetProject/org/example/avail/AvailFactory.java + [java] >> Generating Java class org.example.avail.impl.AvailFactoryImpl + [java] >> Generating /TargetProject/org/example/avail/impl/AvailFactoryImpl.java + [java] >> Examining old /TargetProject/org/example/avail/impl/AvailFactoryImpl.java + [java] >> Generating Quote + [java] >> Generating Java interface org.example.avail.AvailQuote + [java] >> Generating /TargetProject/org/example/avail/AvailQuote.java + [java] >> Examining old /TargetProject/org/example/avail/AvailQuote.java + [java] >> Generating Java class org.example.avail.impl.AvailQuoteImpl + [java] >> Generating /TargetProject/org/example/avail/impl/AvailQuoteImpl.java + [java] >> Examining old /TargetProject/org/example/avail/impl/AvailQuoteImpl.java + [java] >> Generating Request + [java] >> Generating Java interface org.example.avail.AvailRequest + [java] >> Generating /TargetProject/org/example/avail/AvailRequest.java + [java] >> Examining old /TargetProject/org/example/avail/AvailRequest.java + [java] >> Generating Java class org.example.avail.impl.AvailRequestImpl + [java] >> Generating /TargetProject/org/example/avail/impl/AvailRequestImpl.java + [java] >> Examining old /TargetProject/org/example/avail/impl/AvailRequestImpl.java + [java] >> Generating code + [java] >> Generating packages + [java] >> Generating package PricePackageImpl + [java] >> Generating Java interface org.example.price.PriceFactory + [java] >> Generating /TargetProject/org/example/price/PriceFactory.java + [java] >> Examining old /TargetProject/org/example/price/PriceFactory.java + [java] >> Generating Java class org.example.price.impl.PriceFactoryImpl + [java] >> Generating /TargetProject/org/example/price/impl/PriceFactoryImpl.java + [java] >> Examining old /TargetProject/org/example/price/impl/PriceFactoryImpl.java + [java] >> Generating Quote + [java] >> Generating Java interface org.example.price.PriceQuote + [java] >> Generating /TargetProject/org/example/price/PriceQuote.java + [java] >> Examining old /TargetProject/org/example/price/PriceQuote.java + [java] >> Generating Java class org.example.price.impl.PriceQuoteImpl + [java] >> Generating /TargetProject/org/example/price/impl/PriceQuoteImpl.java + [java] >> Examining old /TargetProject/org/example/price/impl/PriceQuoteImpl.java + [java] >> Generating Request + [java] >> Generating Java interface org.example.price.PriceRequest + [java] >> Generating /TargetProject/org/example/price/PriceRequest.java + [java] >> Examining old /TargetProject/org/example/price/PriceRequest.java + [java] >> Generating Java class org.example.price.impl.PriceRequestImpl + [java] >> Generating /TargetProject/org/example/price/impl/PriceRequestImpl.java + [java] >> Examining old /TargetProject/org/example/price/impl/PriceRequestImpl.java + [java] >> Generating Requests + [java] >> Generating Java interface org.example.price.PriceRequests + [java] >> Generating /TargetProject/org/example/price/PriceRequests.java + [java] >> Examining old /TargetProject/org/example/price/PriceRequests.java + [java] >> Generating Java class org.example.price.impl.PriceRequestsImpl + [java] >> Generating /TargetProject/org/example/price/impl/PriceRequestsImpl.java + [java] >> Examining old /TargetProject/org/example/price/impl/PriceRequestsImpl.java + [java] >> Generating Ship Address + [java] >> Generating Java interface org.example.price.ShipAddress + [java] >> Generating /TargetProject/org/example/price/ShipAddress.java + [java] >> Examining old /TargetProject/org/example/price/ShipAddress.java + [java] >> Generating Java class org.example.price.impl.ShipAddressImpl + [java] >> Generating /TargetProject/org/example/price/impl/ShipAddressImpl.java + [java] >> Examining old /TargetProject/org/example/price/impl/ShipAddressImpl.java + +compile: + [jar] Building jar: C:\Apache\tuscany-sca-1.0-incubating-SNAPSHOT\samples\quote-xquery\target\sample-quote-xquery.jar +BUILD SUCCESSFUL + + +The service side: + +run-server: + [java] Sep 18, 2007 1:14:16 PM org.apache.catalina.core.StandardEngine start + [java] INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 + [java] Sep 18, 2007 1:14:16 PM org.apache.catalina.startup.ContextConfig defaultWebConfig + [java] INFO: No default web.xml + [java] Sep 18, 2007 1:14:16 PM org.apache.catalina.startup.DigesterFactory register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd + [java] Sep 18, 2007 1:14:16 PM org.apache.catalina.startup.DigesterFactory register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd + [java] Sep 18, 2007 1:14:16 PM org.apache.catalina.startup.DigesterFactory register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd + [java] Sep 18, 2007 1:14:16 PM org.apache.catalina.startup.DigesterFactory register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_0.xsd + [java] Sep 18, 2007 1:14:16 PM org.apache.catalina.startup.DigesterFactory register + [java] WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xsd + [java] Sep 18, 2007 1:14:17 PM org.apache.coyote.http11.Http11Protocol init + [java] INFO: Initializing Coyote HTTP/1.1 on http-8085 + [java] Sep 18, 2007 1:14:17 PM org.apache.coyote.http11.Http11Protocol start + [java] INFO: Starting Coyote HTTP/1.1 on http-8085 + [java] Sep 18, 2007 1:14:17 PM org.apache.tuscany.sca.http.tomcat.TomcatServer addServletMapping + [java] INFO: Added Servlet mapping: http://localhost:8085/QuoteJoinService + [java] Sep 18, 2007 1:14:17 PM org.apache.tuscany.sca.http.tomcat.TomcatServer addServletMapping + [java] INFO: Added Servlet mapping: http://localhost:8085/AvailQuoteProviderService + [java] XQuery Quote server started (press enter to shutdown) + [java] Sep 18, 2007 1:16:54 PM org.apache.coyote.http11.Http11Protocol destroy + [java] INFO: Stopping Coyote HTTP/1.1 on http-8085 + +BUILD SUCCESSFUL +Total time: 2 minutes 51 seconds + +The client side: +Buildfile: build.xml + +run: + [java] Input quote for the price list: + [java] + [java] + [java] Acme Inc + [java] + [java] + [java] + [java] 12 + [java] 1.0 + [java] + [java] + [java] 134 + [java] 34.1 + [java] + [java] + [java] 211 + [java] 10.0 + [java] + [java] + [java] + [java] + [java] Input quote for the availability: + [java] + [java] + [java] + [java] 12 + [java] 10 + [java] true + [java] 2003-03-22 + [java] + [java] + [java] 134 + [java] 345 + [java] false + [java] BackOrder + [java] + [java] + [java] 211 + [java] 100 + [java] true + [java] 2003-04-21 + [java] + [java] + [java] + [java] + [java] Output quote from local join: + [java] + [java] + [java] Acme Inc + [java]
12 Springs Rd,Morris Plains,NJ,07960
+ [java] + [java] 12 + [java] 1.0 + [java] 10 + [java] true + [java] 2003-03-22 + [java] 0.1 + [java] 11.0 + [java] + [java] + [java] 134 + [java] 34.1 + [java] 345 + [java] false + [java] BackOrder + [java] 0.1 + [java] 0.0 + [java] + [java] + [java] 211 + [java] 10.0 + [java] 100 + [java] true + [java] 2003-04-21 + [java] 0.1 + [java] 1100.0 + [java] + [java]
+ [java] + [java] + [java] Output quote from local join (second invokation): + [java] + [java] + [java] Acme Inc + [java]
12 Springs Rd,Morris Plains,NJ,07960
+ [java] + [java] 12 + [java] 1.0 + [java] 10 + [java] true + [java] 2003-03-22 + [java] 0.2 + [java] 12.0 + [java] + [java] + [java] 134 + [java] 34.1 + [java] 345 + [java] false + [java] BackOrder + [java] 0.2 + [java] 0.0 + [java] + [java] + [java] 211 + [java] 10.0 + [java] 100 + [java] true + [java] 2003-04-21 + [java] 0.2 + [java] 1200.0 + [java] + [java]
+ [java] + [java] + [java] Output quote from web service join: + [java] + [java] + [java] Acme Inc + [java]
12 Springs Rd,Morris Plains,NJ,07960
+ [java] + [java] 12 + [java] 1.0 + [java] 10 + [java] true + [java] 2003-03-22 + [java] 0.1 + [java] 11.0 + [java] + [java] + [java] 134 + [java] 34.1 + [java] 345 + [java] false + [java] BackOrder + [java] 0.1 + [java] 0.0 + [java] + [java] + [java] 211 + [java] 10.0 + [java] 100 + [java] true + [java] 2003-04-21 + [java] 0.1 + [java] 1100.0 + [java] + [java]
+ [java] + [java] + [java] Output quote from properties join: + [java] + [java] + [java] Acme Inc + [java]
12 Springs Rd,Morris Plains,NJ,07960
+ [java] + [java] 12 + [java] 1.0 + [java] 10 + [java] true + [java] 2003-03-22 + [java] 0.1 + [java] 11.0 + [java] + [java] + [java] 134 + [java] 34.1 + [java] 345 + [java] false + [java] BackOrder + [java] 0.1 + [java] 0.0 + [java] + [java] + [java] 211 + [java] 10.0 + [java] 100 + [java] true + [java] 2003-04-21 + [java] 0.1 + [java] 1100.0 + [java] + [java]
+ [java] + [java] + [java] Output quote from external references join: + [java] + [java] + [java] Acme Inc + [java]
12 Springs Rd,Morris Plains,NJ,07960
+ [java] + [java] 12 + [java] 1.0 + [java] 10 + [java] true + [java] 2003-03-22 + [java] 0.1 + [java] 11.0 + [java] + [java] + [java] 134 + [java] 34.1 + [java] 345 + [java] false + [java] BackOrder + [java] 0.1 + [java] 0.0 + [java] + [java] + [java] 211 + [java] 10.0 + [java] 100 + [java] true + [java] 2003-04-21 + [java] 0.1 + [java] 1100.0 + [java] + [java]
+ [java] + +BUILD SUCCESSFUL +Total time: 16 seconds + + + +Sample Overview +--------------- + + 1. There is a central component for invoking the different + scenarios: QuoteJoinLocalComponent + 2. It provides the following cases: + - 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 + +src/main/resources + wsdl + AvailQuote.xsd + PriceQuote.xsd + Quote.xsd + quotejoin.wsdl + META-INF + sca + quote_join_external_references.xq --- the external references xquery script + quote_join_properties.xq --- the property-based join xquery script + quote_join.xq --- the join xquery script + xqueryquotews.composite --- composite file for the client side + xqueryquotewsclient.composite --- composite file for the service side + + build.xml - the Ant build file + pom.xml - the Maven build file + + +Building And Running The Sample Using Ant +----------------------------------------- +cd quote-xquery +ant compile +ant run-server + +you should see: +Buildfile: build.xml + +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. + +cd quote-xquery +mvn + + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/build.xml new file mode 100644 index 0000000000..a3a5acf102 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/build.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/pom.xml new file mode 100644 index 0000000000..b8a294de08 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/pom.xml @@ -0,0 +1,184 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-quote-xquery + Apache Tuscany SCA XQuery Quote Implementation Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-xquery + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sdo + tuscany-sdo-lib + 1.1.1 + + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.1.1 + + + + + + net.sf.saxon + saxon + 8.7 + + + + org.apache.tuscany.sca + tuscany-databinding-sdo + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.4-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.1.1 + + + generate-quotejoin-sdo + generate-sources + + ${basedir}/src/main/resources/wsdl/quotejoin.wsdl + + + generate + + + + 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-20080910/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderImpl.java new file mode 100644 index 0000000000..8a42136b5d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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 QuoteDataUtil.buildAvailQuoteData(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderNodeInfo.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderNodeInfo.java new file mode 100644 index 0000000000..41d78683cc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderNodeInfo.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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; + +@Remotable +public interface AvailQuoteProviderNodeInfo { + NodeInfo provideAvailQuote(String dummyString); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderService.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderService.java new file mode 100644 index 0000000000..f744a59744 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderService.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.avail.AvailQuote; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface AvailQuoteProviderService { + AvailQuote provideAvailQuote(String dummyString); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/ExternalReferencesQuoteJoin.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/ExternalReferencesQuoteJoin.java new file mode 100644 index 0000000000..374c0825e9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/ExternalReferencesQuoteJoin.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.quote.Quote; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface ExternalReferencesQuoteJoin { + public Quote joinPriceAndAvailQuotes(float taxRate); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProvider.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProvider.java new file mode 100644 index 0000000000..fbe38b8269 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProvider.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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; + +@Remotable +public interface PriceQuoteProvider { + + public PriceQuote providePriceQuote(); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderImpl.java new file mode 100644 index 0000000000..d2d175430b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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 QuoteDataUtil.buildPriceQuoteData(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderNodeInfo.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderNodeInfo.java new file mode 100644 index 0000000000..06c3945a6e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderNodeInfo.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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; + +@Remotable +public interface PriceQuoteProviderNodeInfo { + public NodeInfo providePriceQuote(); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/PropertiesQuoteJoin.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/PropertiesQuoteJoin.java new file mode 100644 index 0000000000..1ecdf120c2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/PropertiesQuoteJoin.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 xquery.quote; + +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; + +import org.example.quote.Quote; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface PropertiesQuoteJoin { + @RequestWrapper(className="xquery.quote.joinPriceAndAvailQuotes") + @ResponseWrapper(className="xquery.quote.joinPriceAndAvailQuotesResponse") + public Quote joinPriceAndAvailQuotes(); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculator.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculator.java new file mode 100644 index 0000000000..85508eaa46 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculator.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 xquery.quote; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface QuoteCalculator { + public float calculateTotalPrice(float taxRate, int quantity, float price, boolean fillOrder); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculatorImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculatorImpl.java new file mode 100644 index 0000000000..26331381a8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculatorImpl.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 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-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteDataUtil.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteDataUtil.java new file mode 100644 index 0000000000..8ed02dc1ef --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteDataUtil.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 xquery.quote; + +import java.io.IOException; +import java.math.BigInteger; + + +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 commonj.sdo.DataObject; +import commonj.sdo.helper.XMLHelper; + +public class QuoteDataUtil { + + 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 serializeToSystemOut(DataObject object, String name) { + XMLHelper helper = XMLHelper.INSTANCE; + + try { + helper.save(object, null, name, System.out); + System.out.println(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoin.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoin.java new file mode 100644 index 0000000000..425867055b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoin.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 xquery.quote; + +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; + +import org.example.avail.AvailQuote; +import org.example.price.PriceQuote; +import org.example.quote.Quote; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface QuoteJoin { + @RequestWrapper(className="xquery.quote.joinPriceAndAvailQuotes") + @ResponseWrapper(className="xquery.quote.joinPriceAndAvailQuotesResponse") + public Quote joinPriceAndAvailQuotes(PriceQuote priceQuote, AvailQuote availQuote, float taxRate); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocal.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocal.java new file mode 100644 index 0000000000..cfd201f883 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocal.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 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-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocalImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocalImpl.java new file mode 100644 index 0000000000..20fe73fd92 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteClient.java new file mode 100644 index 0000000000..adc852acd4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteClient.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.example.avail.AvailQuote; +import org.example.price.PriceQuote; +import org.example.quote.Quote; + +import commonj.sdo.DataObject; + +/** + * Integration test for the XQuery implementation type + * @version $Rev: 577067 $ $Date: 2007-09-18 22:10:03 +0100 (Tue, 18 Sep 2007) $ + * 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 XQueryQuoteClient { + + public static boolean SHOW_DEBUG_MSG = false; + + private SCADomain scaDomain; + + private QuoteJoinLocal quoteJoinLocal; + + public void startClient() throws Exception { + try { + scaDomain = SCADomain.newInstance("xqueryquotewsclient.composite"); + quoteJoinLocal = scaDomain.getService(QuoteJoinLocal.class, "QuoteJoinLocalComponent"); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + public void testQuoteJoin() { + AvailQuote availQuote = QuoteDataUtil.buildAvailQuoteData(); + PriceQuote priceQuote = QuoteDataUtil.buildPriceQuoteData(); + + if (SHOW_DEBUG_MSG) { + System.out.println("Input quote for the price list:"); + QuoteDataUtil.serializeToSystemOut((DataObject)priceQuote, "priceQuote"); + System.out.println(); + System.out.println("Input quote for the availability:"); + QuoteDataUtil.serializeToSystemOut((DataObject)availQuote, "availQuote"); + System.out.println(); + } + + Quote quote = quoteJoinLocal.joinPriceAndAvailQuotes(priceQuote, availQuote, 0.1f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from local join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + // TestHelper.assertQuote(availQuote, priceQuote, quote, 0.1f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotes(priceQuote, availQuote, 0.2f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from local join (second invokation):"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + // TestHelper.assertQuote(availQuote, priceQuote, quote, 0.2f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotesWs(priceQuote, availQuote, 0.1f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from web service join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + // TestHelper.assertQuote(availQuote, priceQuote, quote, 0.1f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotes(); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from properties join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + // TestHelper.assertQuote(availQuote, priceQuote, quote, 0.1f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotes(0.1f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from external references join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + // TestHelper.assertQuote(availQuote, priceQuote, quote, 0.1f); + } + + public void stopClient() throws Exception { + if (scaDomain != null) { + scaDomain.close(); + } + } + + public static void main(String[] args) throws Exception { + SHOW_DEBUG_MSG = true; + XQueryQuoteClient client = new XQueryQuoteClient(); + client.startClient(); + try { + client.testQuoteJoin(); + } finally { + client.stopClient(); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteServer.java new file mode 100644 index 0000000000..3fa3cdb637 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteServer.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 xquery.quote; + +import java.io.IOException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class XQueryQuoteServer { + + public static void main(String[] args) { + SCADomain scaDomain = SCADomain.newInstance("xqueryquotews.composite"); + try { + System.out.println("XQuery Quote server is started (press enter to shutdown)."); + System.in.read(); + System.out.println("XQuery Quote server is stopping..."); + } catch (IOException e) { + e.printStackTrace(); + } + scaDomain.close(); + System.out.println("XQuery Quote server is now stopped."); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq new file mode 100644 index 0000000000..d504f40f04 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq @@ -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. +:) + +declare namespace quoteJoin="scaservice:java/xquery.quote.QuoteJoin"; + +declare namespace quoteCalculator="scareference:java/xquery.quote.QuoteCalculator"; + +declare namespace quo="http://www.example.org/quote"; + +declare variable $quoteCalculator external; + +declare function quoteJoin:joinPriceAndAvailQuotes($priceQuoteDoc, $availQuoteDoc, $taxRate) { + + { data($priceQuoteDoc/*/customerName) } + { concat($priceQuoteDoc/*/shipAddress/@street , ",", $priceQuoteDoc/*/shipAddress/@city ,",", fn:upper-case($priceQuoteDoc/*/shipAddress/@state) , ",", $priceQuoteDoc/*/shipAddress/@zip) } + { + for $priceRequest in $priceQuoteDoc/*/priceRequests/priceRequest, + $availRequest in $availQuoteDoc/*/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, + + xs:float($taxRate), + + $availRequest/requestedQuantity, + + $priceRequest/price, + + $availRequest/quantityAvail) } + + } + +}; diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_external_references.xq b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_external_references.xq new file mode 100644 index 0000000000..cc50da164a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_external_references.xq @@ -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. +:) +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 namespace quo="http://www.example.org/quote"; + +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) } + + } + +}; diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_properties.xq b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_properties.xq new file mode 100644 index 0000000000..cf41ab528d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_properties.xq @@ -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. +:) + +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 namespace pri="http://www.example.org/price"; +declare namespace ava="http://www.example.org/avail"; +declare namespace quo="http://www.example.org/quote"; + +declare variable $quoteCalculator external; + +declare variable $priceQuoteDoc external; +declare variable $availQuoteDoc external; +declare variable $taxRate external; + +declare function quoteJoin:joinPriceAndAvailQuotes() { + + { data($priceQuoteDoc/pri:priceQuote/customerName) } + { concat($priceQuoteDoc/pri:priceQuote/shipAddress/@street , ",", + $priceQuoteDoc/pri:priceQuote/shipAddress/@city ,",", + fn:upper-case($priceQuoteDoc/pri:priceQuote/shipAddress/@state) , ",", + $priceQuoteDoc/pri:priceQuote/shipAddress/@zip) } + { + for $priceRequest in $priceQuoteDoc/pri:priceQuote/priceRequests/priceRequest, + $availRequest in $availQuoteDoc/ava: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) } + + } + +}; diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/wsdl/AvailQuote.xsd b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/quote-xquery/src/main/resources/wsdl/AvailQuote.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/wsdl/PriceQuote.xsd b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/quote-xquery/src/main/resources/wsdl/PriceQuote.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/wsdl/Quote.xsd b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/quote-xquery/src/main/resources/wsdl/Quote.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl new file mode 100644 index 0000000000..96c2af138a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/xqueryquotews.composite b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/xqueryquotews.composite new file mode 100644 index 0000000000..9e35e2ecb2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/xqueryquotews.composite @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite new file mode 100644 index 0000000000..35306b9f89 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + 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-20080910/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteClientTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteClientTestCase.java new file mode 100644 index 0000000000..9555532b3e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteClientTestCase.java @@ -0,0 +1,192 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package xquery.quote; + +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.host.embedded.SCATestCaseRunner; +import org.example.avail.AvailQuote; +import org.example.avail.AvailRequest; +import org.example.price.PriceQuote; +import org.example.price.PriceRequest; +import org.example.price.ShipAddress; +import org.example.quote.Quote; +import org.example.quote.QuoteResponse; +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 = QuoteDataUtil.buildAvailQuoteData(); + PriceQuote priceQuote = QuoteDataUtil.buildPriceQuoteData(); + + if (SHOW_DEBUG_MSG) { + System.out.println("Input quote for the price list:"); + QuoteDataUtil.serializeToSystemOut((DataObject)priceQuote, "priceQuote"); + System.out.println(); + System.out.println("Input quote for the availability:"); + QuoteDataUtil.serializeToSystemOut((DataObject)availQuote, "availQuote"); + System.out.println(); + } + + Quote quote = quoteJoinLocal.joinPriceAndAvailQuotes(priceQuote, availQuote, 0.1f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from local join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + XQueryQuoteClientTestCase.assertQuote(availQuote, priceQuote, quote, 0.1f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotes(priceQuote, availQuote, 0.2f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from local join (second invokation):"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + XQueryQuoteClientTestCase.assertQuote(availQuote, priceQuote, quote, 0.2f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotesWs(priceQuote, availQuote, 0.1f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from web service join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + XQueryQuoteClientTestCase.assertQuote(availQuote, priceQuote, quote, 0.1f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotes(); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from properties join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + XQueryQuoteClientTestCase.assertQuote(availQuote, priceQuote, quote, 0.1f); + + quote = quoteJoinLocal.joinPriceAndAvailQuotes(0.1f); + if (SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from external references join:"); + QuoteDataUtil.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + XQueryQuoteClientTestCase.assertQuote(availQuote, priceQuote, quote, 0.1f); + } + + @After + public void stopClient() throws Exception { + server.after(); + scaDomain.close(); + } + + 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 < availRequests.size(); i++) { + AvailRequest availRequest = (AvailRequest)availRequests.get(i); + PriceRequest priceRequest = (PriceRequest)priceRequests.get(i); + QuoteResponse quoteResponse = (QuoteResponse)quoteResponses.get(i); + TestCase.assertEquals(availRequest.getWidgetId(), quoteResponse.getWidgetId()); + TestCase.assertEquals(priceRequest.getPrice(), quoteResponse.getUnitPrice()); + TestCase.assertEquals(availRequest.getRequestedQuantity(), quoteResponse.getRequestedQuantity()); + TestCase.assertEquals(availRequest.isQuantityAvail(), quoteResponse.isFillOrder()); + if (availRequest.getShipDate() == null) { + TestCase.assertNull(quoteResponse.getShipDate()); + } else { + TestCase.assertEquals(availRequest.getShipDate(), quoteResponse.getShipDate()); + } + TestCase.assertEquals(taxRate, quoteResponse.getTaxRate()); + TestCase.assertEquals(quoteCalculatorImpl.calculateTotalPrice(taxRate, + availRequest.getRequestedQuantity(), + priceRequest.getPrice(), + availRequest.isQuantityAvail()), + quoteResponse.getTotalCost()); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteTestServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteTestServer.java new file mode 100644 index 0000000000..9a4be5bda6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/simple-bigbank-spring/README b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/README new file mode 100644 index 0000000000..bb44d63719 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/README @@ -0,0 +1,148 @@ +Spring Bigbank Sample +====================== +This sample is made of 3 modules that represent the different aspects of a fictitious banking application. + +To run the simple-bigbank-spring sample you need to first run spring-bigbank-calculator, spring-bigbank-checkaccount and spring-bigbank-stockquote composites. +This will bring up Tuscany runtime and load the three applications and make them available as services. +Bigbank-Spring is dependent on these services. + +This demo uses ant. This is just one way of running this demo. + +Start Spring-Bigbank-calculator Composite +----------------------------------------- + +Spring-Bigbank-calculator is a calculator application which handles add, subtract, multiply and divide operations. Each of these operations is implemented in a different language, including JavaScript, groovy, Ruby and Python. + +To run the spring-bigbank-calculator composite and make it available as a service for this demo do the following: + +cd spring-bigbank-calculator +ant compile +ant run + +.. Leave the server running + +Note that 'ant compile' needs to be done the first time you run this demo out of the binary distribution. No need to do 'ant compile' from there on. + +Start Spring-Bigbank-checkaccount Composite +------------------------------------------- + +This contains all artifacts that deal with the account management within the bigbank. The services offered by the bigbank-account module are used by the bigbank. + +cd spring-bigbank-checkaccount +ant compile +ant run + +.. Leave the server running + +Note that 'ant compile' needs to be done the first time you run this demo out of the binary distribution. No need to do 'ant compile' from there on. + +Start Spring-Bigbank-stockquote Composite +----------------------------------------- + +A very simple web services based stock quote application which returns random +stock quotes on request. Please note that the stockquote service is not live and is implemented instead to allow for this application to always run without dependency on the availability of a webservice. + +cd spring-bigbank-stockquote +ant compile +ant run + +.. Leave the server running + +Start Spring Bigbank +-------------------- +This contains all artifacts that make up the bigbank application. This is the application that the end user interacts with + +Start spring-bigbank in the following way: + +i ) Compile the spring-bigbank as follows : + + cd simple-bigbank-spring + ant compile + +ii) Now start the bigbank service as follows : + + cd bigbank + ant compile + ant run + + .. Leave the server running + +Note that 'ant compile' needs to be done the first time you run this demo out ofthe binary distribution. +No need to do 'ant compile' from there on. + +Sample Overview +--------------- +This sample demonstrates a simple bank summary transaction using Spring for one of the components. + +A request to the AccountComponent results in a request to the AccountDataComponent to get account data +which is based on a random stock quote price. Therefore result for this sample will vary on each run. + + +simple-bigbank-spring/ + src/ + main/ + java/ + bigbank/ + account/ - AccountComponent implementation using Spring + accountdata/ - AccountDataComponent implementation using Spring + sockquote/ - stockquote implementation using Java + 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. +** Please note that balance amount will vary depending on the random stock value. + +run: + [java] Spring parent context - getBean called for name: stockQuoteService + [java] Getting stock quote for: IBM, value: 104.97 + [java] Account summary: currency: USD, [ID:Foo_CHA12345, balance:1500.0, ID +:Foo_SAA12345, balance:1500.0, ID:Foo_STA12345, symbol:IBM, quantity:100, balance:10497.0] + + +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. +** Please note that balance amount will vary depending on the random stock value. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running bigbank.BigBankTestCase +Getting stock quote for: IBM, value: 104.02 +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:10402.0] +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.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-20080910/samples/simple-bigbank-spring/build-dojo.xml b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/build-dojo.xml new file mode 100644 index 0000000000..9d282c2dd2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/build-dojo.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/build.xml new file mode 100644 index 0000000000..ecc2596d71 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/pom.xml new file mode 100644 index 0000000000..9e5dc673b9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/pom.xml @@ -0,0 +1,252 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-simple-bigbank-spring + Apache Tuscany SCA Spring-Based Simplified BigBank Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 1.4-SNAPSHOT + + + + org.apache.ws.security + wss4j + 1.5.3 + + + + commons-httpclient + commons-httpclient + 3.0.1 + + + + commons-logging + commons-logging + 1.1 + + + javax.servlet + servlet-api + + + + + + org.apache.tuscany.sca + tuscany-data-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-spring + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-rmi + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-rss-rome + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-resource-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.4-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-20080910/samples/simple-bigbank-spring/simple-bigbank-spring.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/simple-bigbank-spring/simple-bigbank-spring.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/simple-bigbank-spring.svg b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountReport.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountServiceImpl.java new file mode 100644 index 0000000000..ce41006fa6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountServiceImpl.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 bigbank.account; + +import java.util.ArrayList; +import java.util.List; + +import org.osoa.sca.annotations.Service; + +import bigbank.account.checking.CheckingAccountDetails; +import bigbank.account.checking.CheckingAccountService; +import bigbank.account.savings.SavingsAccountDetails; +import bigbank.account.savings.SavingsAccountService; +import bigbank.account.stock.StockAccountDetails; +import bigbank.account.stock.StockAccountService; +import bigbank.stockquote.StockQuoteService; +import bigbank.calculator.CalculatorService; + +/** + * Account service implementation + */ +@Service(AccountService.class) +public class AccountServiceImpl implements AccountService { + + private SavingsAccountService savingsAccountService; + + private CheckingAccountService checkingAccountService; + + private StockAccountService stockAccountService; + + private CalculatorService calculatorService; + + private StockQuoteService stockQuoteService; + + private String currency; + + public AccountReport getAccountReport(String customerID) { + + // Get the checking, savings and stock accounts from the AccountData + // service component + CheckingAccountDetails checking = null; + List summaries = new ArrayList(); + try { + checking = checkingAccountService.getAccountDetails(customerID); + System.out.println("Checking account: " + checking); + summaries.add(checking.toString()); + + SavingsAccountDetails savings = savingsAccountService.getAccountDetails(customerID); + System.out.println("Savings account: " + savings); + summaries.add(savings.toString()); + + StockAccountDetails stock = stockAccountService.getAccountDetails(customerID); + System.out.println("Stock account: " + stock); + summaries.add(stock.toString()); + + // Get the stock price in USD + double price = stockQuoteService.getQuote(stock.getSymbol()); + System.out.println("Stock price for " + stock.getSymbol() + ": " + price); + + // Convert to the configured currency + if (currency.equals("EURO")) { + + // Use our fancy calculator service to convert to the target currency + price = calculatorService.multiply(price, 0.70); + + System.out.println("Converted to " + currency + ": " + price); + } + + // Calculate the value of the stock account + double stockValue = price * stock.getQuantity(); + summaries.add(stock.toString()); + + AccountReport report = new AccountReport(currency, summaries); + + return report; + } catch ( Throwable e ) { + e.printStackTrace(); + return null; + } + } + + public SavingsAccountService getSavingsAccountService() { + return savingsAccountService; + } + + public void setSavingsAccountService(SavingsAccountService savingsAccountService) { + this.savingsAccountService = savingsAccountService; + } + + public CheckingAccountService getCheckingAccountService() { + return checkingAccountService; + } + + public void setCheckingAccountService(CheckingAccountService checkingAccountService) { + this.checkingAccountService = checkingAccountService; + } + + public StockAccountService getStockAccountService() { + return stockAccountService; + } + + public void setStockAccountService(StockAccountService stockAccountService) { + this.stockAccountService = stockAccountService; + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } + + public CalculatorService getCalculatorService() { + return calculatorService; + } + + public void setCalculatorService(CalculatorService calculatorService) { + this.calculatorService = calculatorService; + } + + public StockQuoteService getStockQuoteService() { + return stockQuoteService; + } + + public void setStockQuoteService(StockQuoteService stockQuoteService) { + this.stockQuoteService = stockQuoteService; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountDetails.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountDetails.java new file mode 100644 index 0000000000..3f81f48fb9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountDetails.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.account.checking; + +public class CheckingAccountDetails { + 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; + } + + @Override + public String toString() { + return accountNumber + ", balance:" + balance; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountService.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountService.java new file mode 100644 index 0000000000..2b52909bc1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountService.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 bigbank.account.checking; + +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +@Service +@Remotable +public interface CheckingAccountService { + + public CheckingAccountDetails getAccountDetails(String customerID); + + public double deposit(String accountNo, double depositAmt); + + public double withdraw(String accountNo, double withdrawalAmount); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/feed/AccountFeedImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/feed/AccountFeedImpl.java new file mode 100644 index 0000000000..386f7bb90d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/feed/AccountFeedImpl.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 bigbank.account.feed; + +import org.apache.tuscany.sca.data.collection.Collection; +import org.apache.tuscany.sca.data.collection.Entry; +import org.apache.tuscany.sca.data.collection.NotFoundException; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import bigbank.account.AccountService; +import bigbank.account.AccountReport; + +/** + * @version $$Rev$$ $$Date$$ + */ + +@Service(Collection.class) +public class AccountFeedImpl implements Collection { + + @Reference + protected AccountService accountService; + + public Entry[] getAll() { + + // Add the Account report entry + String report = get("1234"); + Entry entry = new Entry("1234", report); + + return new Entry[] { entry } ; + } + + public String get(String id) { + + // Get the account report for the specified customer ID + AccountReport accreport = accountService.getAccountReport(id); + String report = accreport.getCurrency(); + + return report; + } + + public void delete(String key) throws NotFoundException { + } + + public String post(String key, String item) { + return null; + } + + public void put(String key, String item) throws NotFoundException { + } + + public Entry[] query(String queryString) { + return null; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountDetails.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountDetails.java new file mode 100644 index 0000000000..bcac678cd7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountDetails.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.savings; + +import java.io.Serializable; + +public class SavingsAccountDetails implements Serializable { + 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; + } + + @Override + public String toString() { + return accountNumber + ", balance:" + balance; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountService.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountService.java new file mode 100644 index 0000000000..8a012c12f9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountService.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.account.savings; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface SavingsAccountService { + + public SavingsAccountDetails getAccountDetails(String customerID); + + public double deposit(String accountNo, double depositAmt); + + public double withdraw(String accountNo, double withdrawalAmount); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java new file mode 100644 index 0000000000..980ec1c335 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.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 bigbank.account.savings; + +import java.util.HashMap; +import java.util.Map; + +import org.osoa.sca.annotations.Service; + +@Service(SavingsAccountService.class) +public class SavingsAccountServiceImpl implements SavingsAccountService { + private Map custAcctMap = new HashMap(); + private Map savingsAccts = new HashMap(); + + public SavingsAccountServiceImpl() { + custAcctMap.put("Customer_01", "SVA_Customer_01"); + custAcctMap.put("Customer_02", "SVA_Customer_02"); + custAcctMap.put("Customer_03", "SVA_Customer_03"); + + savingsAccts.put("SVA_Customer_01", new Double(1000)); + savingsAccts.put("SVA_Customer_02", new Double(1500)); + savingsAccts.put("SVA_Customer_03", new Double(2000)); + } + + public double deposit(String accountNo, double depositAmt) { + savingsAccts.put(accountNo, new Double(savingsAccts.get(accountNo).doubleValue() + depositAmt)); + return savingsAccts.get(accountNo).doubleValue(); + } + + public SavingsAccountDetails getAccountDetails(String customerID) { + SavingsAccountDetails savingsAccount = new SavingsAccountDetails(); + savingsAccount.setAccountNumber(custAcctMap.get(customerID)); + savingsAccount.setBalance(savingsAccts.get(savingsAccount.getAccountNumber()).doubleValue()); + + return savingsAccount; + } + + public double withdraw(String accountNo, double withdrawalAmount) { + double balance = savingsAccts.get(accountNo).doubleValue(); + if ( balance - withdrawalAmount > 0 ) { + balance = balance - withdrawalAmount; + savingsAccts.put(accountNo, balance); + } + return balance; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountDetails.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountDetails.java new file mode 100644 index 0000000000..9f06a71bae --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountDetails.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 bigbank.account.stock; + +public class StockAccountDetails { + private String accountNumber; + private String symbol; + private int quantity; + + public StockAccountDetails() { + } + + public StockAccountDetails(String acNo, String symbol, int qty) { + this.accountNumber = acNo; + this.symbol = symbol; + this.quantity = qty; + } + + public String getAccountNumber() { + return accountNumber; + } + + public void setAccountNumber(String n) { + this.accountNumber = n; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int a) { + this.quantity = a; + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String s) { + this.symbol = s; + } + + @Override + public String toString() { + return accountNumber + ", symbol:" + symbol + ", quantity:" + quantity; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountService.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountService.java new file mode 100644 index 0000000000..1ee386ba90 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountService.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 bigbank.account.stock; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface StockAccountService { + + public StockAccountDetails getAccountDetails(String customerID); + + public StockAccountDetails buy(String accountNo, String symbol, int quantity); + + public StockAccountDetails sell(String accountNo, String symbol, int quantity); + + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java new file mode 100644 index 0000000000..61aea6869e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountServiceImpl.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.stock; + +import java.util.HashMap; +import java.util.Map; + +import org.osoa.sca.annotations.Service; + +@Service(StockAccountService.class) +public class StockAccountServiceImpl implements StockAccountService { + private Map custAcctMap = new HashMap(); + private Map stockAccts = new HashMap(); + + public StockAccountServiceImpl() { + custAcctMap.put("Customer_01", "STA_Customer_01"); + custAcctMap.put("Customer_02", "STA_Customer_02"); + custAcctMap.put("Customer_03", "STA_Customer_03"); + + stockAccts.put("STA_Customer_01", new StockAccountDetails("STA_Customer_01", "IBM", 100)); + stockAccts.put("STA_Customer_02", new StockAccountDetails("STA_Customer_02", "IBM", 200)); + stockAccts.put("STA_Customer_03", new StockAccountDetails("STA_Customer_03", "SYM_3", 125)); + } + + + public StockAccountDetails buy(String accountNo, String symbol, int quantity) { + return null; + } + + public StockAccountDetails getAccountDetails(String customerID) { + return stockAccts.get(custAcctMap.get(customerID)); + } + + public StockAccountDetails sell(String accountNo, String symbol, int quantity) { + return null; + } + + + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/calculator/CalculatorService.java new file mode 100644 index 0000000000..66a0ba0e63 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/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 bigbank.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-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java new file mode 100644 index 0000000000..f7b940f873 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.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 bigbank.client; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; + +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 { + + SCANodeFactory factory = SCANodeFactory.newInstance(); + SCANode node = factory.createSCANodeFromClassLoader("BigBank.composite", BigBankClient.class.getClassLoader()); + node.start(); + + AccountService accountService = ((SCAClient)node).getService(AccountService.class, "AccountServiceComponent"); + + System.out.println("Account summary: " + accountService.getAccountReport("Customer_01") ); + + node.stop(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/server/BigBankServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/server/BigBankServer.java new file mode 100644 index 0000000000..241347e417 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/server/BigBankServer.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.server; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +public class BigBankServer { + + public static void main(String[] args) throws Exception { + long timeout = -1L; + if (args.length > 0) { + timeout = Long.parseLong(args[0]); + } + + System.out.println("Starting the Sample SCA Spring BigBank server..."); + + SCANodeFactory factory = SCANodeFactory.newInstance(); + SCANode node = factory.createSCANodeFromClassLoader("BigBank.composite", BigBankServer.class.getClassLoader()); + node.start(); + + if (timeout < 0) { + System.out.println("Press Enter to Exit..."); + System.in.read(); + } else { + Thread.sleep(timeout); + } + + node.stop(); + + System.out.println("Bye"); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/java/bigbank/stockquote/StockQuoteService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank-spring/src/main/resources/BigBank.composite b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/BigBank.composite new file mode 100644 index 0000000000..ea2dbc7e1c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/BigBank.composite @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/SavingsAccount.composite b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/SavingsAccount.composite new file mode 100644 index 0000000000..4bb2ce61ef --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/SavingsAccount.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/StockAccount.composite b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/StockAccount.composite new file mode 100644 index 0000000000..97dff499ba --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/StockAccount.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/Account-spring-context.xml b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/Account-spring-context.xml new file mode 100644 index 0000000000..899d8d7d62 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/Account-spring-context.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/SavingsAccount-context.xml b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/SavingsAccount-context.xml new file mode 100644 index 0000000000..b9e26bf81b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/SavingsAccount-context.xml @@ -0,0 +1,33 @@ + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/StockAccount/META-INF/MANIFEST.MF b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/StockAccount/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..32fa070ffb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/StockAccount/META-INF/MANIFEST.MF @@ -0,0 +1,4 @@ +Manifest-Version: 1.0 +Spring-Context: META-INF/spring/StockAccount-context.xml + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/StockAccount/META-INF/spring/StockAccount-context.xml b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/StockAccount/META-INF/spring/StockAccount-context.xml new file mode 100644 index 0000000000..b30f821f7e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/spring-context/StockAccount/META-INF/spring/StockAccount-context.xml @@ -0,0 +1,33 @@ + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/web/style.css b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/web/style.css new file mode 100644 index 0000000000..1071583264 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/main/resources/web/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-20080910/samples/simple-bigbank-spring/src/test/java/bigbank/BigBankTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/test/java/bigbank/BigBankTestCase.java new file mode 100644 index 0000000000..d82e383e46 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank-spring/src/test/java/bigbank/BigBankTestCase.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 bigbank; + +import junit.framework.TestCase; + +import bigbank.server.BigBankServer; + +/** + * Tests out the big bank service + * + */ +public class BigBankTestCase extends TestCase { + + public void testServer() throws Exception { + BigBankServer.main(new String[] {"1000"}); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/README b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/README new file mode 100644 index 0000000000..acbe93a4d3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/README @@ -0,0 +1,101 @@ +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 +--------------- +This sample demonstrates a simple bank summary transaction while using Java components wired together. +SCA default binding is used. + +A request to the AccountComponent results in a request to the AccountDataComponent to get account data +which is based on a random stock quote price. Therefore result for this sample will vary on each run. + +calculator/ + src/ + main/ + java/ + bigbank/ + account/ - AccountComponent implementation + accountdata/ - AccountDataComponent implementation + stockquote/ - generates random stock prices + 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. +** Please note that the balance amount is dependent on the random sotck quote price and the +numbers may vary on each run. + +run: + [java] Getting stock quote for: IBM, value: 104.06 + [java] Account summary: currency: USD, [ID:Foo_CHA12345, balance:1500.0, ID +:Foo_SAA12345, balance:1500.0, ID:Foo_STA12345, symbol:IBM, quantity:100, balanc +e:10406.0] + + +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. +** Please note that the balance amount is dependent on the random sotck quote price and the numbers may vary on each run. + + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running bigbank.BigBankTestCase +Getting stock quote for: IBM, value: 104.02 +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:10402.0] +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.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-20080910/samples/simple-bigbank/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/build.xml new file mode 100644 index 0000000000..a814014eae --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/pom.xml new file mode 100644 index 0000000000..bb99d5cd6c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-simple-bigbank + Apache Tuscany SCA Simplified BigBank Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/simple-bigbank.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/simple-bigbank/simple-bigbank.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/simple-bigbank.svg b/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/simple-bigbank.svg new file mode 100644 index 0000000000..c64f6de6b9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/simple-bigbank/src/main/java/bigbank/account/AccountReport.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank/src/main/java/bigbank/account/AccountService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank/src/main/java/bigbank/account/AccountServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank/src/main/java/bigbank/accountdata/Account.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank/src/main/java/bigbank/accountdata/CheckingAccount.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank/src/main/java/bigbank/accountdata/SavingsAccount.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank/src/main/java/bigbank/accountdata/StockAccount.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank/src/main/java/bigbank/client/BigBankClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-bigbank/src/main/resources/Account.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/simple-bigbank/src/main/resources/Account.composite @@ -0,0 +1,38 @@ + + + + + + + + + + USD + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/resources/BigBank.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/simple-bigbank/src/main/resources/BigBank.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/main/resources/StockQuote.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/simple-bigbank/src/main/resources/StockQuote.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-bigbank/src/test/java/bigbank/BigBankTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-callback-ws/README b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/README new file mode 100644 index 0000000000..6b27718f74 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/README @@ -0,0 +1,144 @@ +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] 14-Jan-2008 14:25:02 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:8085/MyServiceCallbackCo +mponent + [java] 14-Jan-2008 14:25:02 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:8085/MyServiceComponent + [java] Main thread Thread[main,5,main] + [java] aClientMethod on thread Thread[main,5,main] + [java] aClientMethod return from someMethod on thread Thread[main,5,main] + [java] setMyServiceCallback on thread Thread[pool-1-thread-2,5,main] + [java] someMethod on thread Thread[pool-1-thread-2,5,main] + [java] receiveResult on thread Thread[pool-1-thread-4,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-ws +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running simplecallback.SimpleCallbackTestCase +14-Jan-2008 14:26:28 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +14-Jan-2008 14:26:28 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +14-Jan-2008 14:26:28 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +14-Jan-2008 14:26:28 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +1.dtd +14-Jan-2008 14:26:28 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +2.dtd +14-Jan-2008 14:26:28 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +14-Jan-2008 14:26:28 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +14-Jan-2008 14:26:28 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:26:28 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8085 +14-Jan-2008 14:26:28 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8085/MyServiceCallbackComponent +14-Jan-2008 14:26:28 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8085/MyServiceComponent +Main thread Thread[main,5,main] +aClientMethod on thread Thread[main,5,main] +aClientMethod return from someMethod on thread Thread[main,5,main] +Sleeping ... +setMyServiceCallback on thread Thread[pool-1-thread-1,5,main] +someMethod on thread Thread[pool-1-thread-1,5,main] +receiveResult on thread Thread[pool-1-thread-2,5,main] +Result: -> someMethod -> receiveResult +14-Jan-2008 14:26:31 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.312 sec + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/build.xml new file mode 100644 index 0000000000..10b69bd395 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/pom.xml new file mode 100644 index 0000000000..d3482afb8b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-simple-callback-ws + Apache Tuscany SCA Simple Callback Web Service Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/simple-callback-ws.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/simple-callback-ws/simple-callback-ws.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/simple-callback-ws.svg b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-callback-ws/src/main/java/simplecallback/MyClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-callback-ws/src/main/java/simplecallback/MyClientImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/main/java/simplecallback/MyClientImpl.java new file mode 100644 index 0000000000..ad7c6d8fef --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/simple-callback-ws/src/main/java/simplecallback/MyService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceCallback.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceImpl.java new file mode 100644 index 0000000000..08057d2fcc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/simple-callback-ws/src/main/java/simplecallback/SimpleCallbackClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-callback-ws/src/main/resources/simplecallback.composite b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/main/resources/simplecallback.composite new file mode 100644 index 0000000000..53e7fe66af --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/main/resources/simplecallback.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl new file mode 100644 index 0000000000..8a6465de3a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/test/java/simplecallback/SimpleCallbackTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback-ws/src/test/java/simplecallback/SimpleCallbackTestCase.java new file mode 100644 index 0000000000..580a7f6b0c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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(2000); + assertEquals("-> someMethod -> receiveResult", MyClientImpl.result); + } +} + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/README b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/README new file mode 100644 index 0000000000..719376f254 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/simple-callback/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/build.xml new file mode 100644 index 0000000000..47d1ea4bc1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/pom.xml new file mode 100644 index 0000000000..3a449dade9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-simple-callback + Apache Tuscany SCA Simple Callback Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/simple-callback.png b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/simple-callback/simple-callback.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/simple-callback.svg b/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/simple-callback.svg new file mode 100644 index 0000000000..484b65df9d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/simple-callback/src/main/java/simplecallback/MyClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-callback/src/main/java/simplecallback/MyClientImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-callback/src/main/java/simplecallback/MyService.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-callback/src/main/java/simplecallback/MyServiceCallback.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-callback/src/main/java/simplecallback/MyServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-callback/src/main/java/simplecallback/SimpleCallbackClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/simple-callback/src/main/resources/simplecallback.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/simple-callback/src/main/resources/simplecallback.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/simple-callback/src/test/java/simplecallback/SimpleCallbackTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/spi-implementation-pojo/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/spi-implementation-pojo/pom.xml new file mode 100644 index 0000000000..c78d035eba --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spi-implementation-pojo/pom.xml @@ -0,0 +1,59 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-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 + 1.4-SNAPSHOT + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementation.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementationActivator.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/spi-implementation-pojo/src/main/java/sample/JavaInvoker.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/spi-implementation-pojo/src/main/java/sample/JavaInvokerFactory.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/spi-implementation-pojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorld.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/spi-implementation-pojo/src/test/resources/helloworld/helloworld.composite b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/spi-implementation-pojo/src/test/resources/helloworld/helloworld.composite @@ -0,0 +1,28 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/README b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/README new file mode 100644 index 0000000000..3869ea6a12 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/README @@ -0,0 +1,2 @@ +Spring-bigbank-calculator is part of a spring-bigbank sample. +Please see the Readme file under spring-bigbank to understand how spring-bigbank-calculator fits into the overall picture. diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/build.xml new file mode 100644 index 0000000000..9d69ee9ba0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/pom.xml new file mode 100644 index 0000000000..45117a03de --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/pom.xml @@ -0,0 +1,92 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-spring-bigbank-calculator + Apache Tuscany SCA Spring-Based BigBank Calculator Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-script + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-spring + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-rmi + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/AddService.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/AddService.java new file mode 100644 index 0000000000..ecaa4e28de --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/AddService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.calculator; + +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/CalculatorService.java new file mode 100644 index 0000000000..66a0ba0e63 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/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 bigbank.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-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..2a529dddeb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/CalculatorServiceImpl.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.calculator; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * An implementation of the Calculator service. + */ +@Service(CalculatorService.class) +public class CalculatorServiceImpl implements CalculatorService { + + private AddService addService; + private SubtractService subtractService; + private MultiplyService multiplyService; + private DivideService divideService; + + @Reference + public void setAddService(AddService addService) { + this.addService = addService; + } + + @Reference + public void setSubtractService(SubtractService subtractService) { + this.subtractService = subtractService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + @Reference + public void setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + public double add(double n1, double n2) { + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + System.err.println("Multiply"); + 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-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/DivideService.java new file mode 100644 index 0000000000..22e9d58a94 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/DivideService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.calculator; + +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/MultiplyService.java new file mode 100644 index 0000000000..ba3d43448e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/MultiplyService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.calculator; + +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/SubtractService.java new file mode 100644 index 0000000000..17691af0e8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/SubtractService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.calculator; + +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/server/CalculatorServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/server/CalculatorServer.java new file mode 100644 index 0000000000..b0737899dc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/server/CalculatorServer.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 bigbank.calculator.server; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; + +public class CalculatorServer { + + public static void main(String[] args) throws Exception { + + System.out.println("Starting the Sample SCA Calculator..."); + + SCANodeFactory factory = SCANodeFactory.newInstance(); + SCANode node = factory.createSCANodeFromClassLoader("Calculator.composite", CalculatorServer.class.getClassLoader()); + node.start(); + + System.out.println("Press Enter to Exit..."); + System.in.read(); + + node.stop(); + + System.out.println("Bye"); + System.exit(0); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/Calculator.composite b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..504a4ccfcd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/Calculator.composite @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/META-INF/spring/CalculatorService-context.xml b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/META-INF/spring/CalculatorService-context.xml new file mode 100644 index 0000000000..42e5f824f9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/META-INF/spring/CalculatorService-context.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/AddServiceImpl.js b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/AddServiceImpl.js new file mode 100644 index 0000000000..6f11106ddd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/AddServiceImpl.js @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +function add(n1, n2) { + return n1 + n2; +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/DivideServiceImpl.groovy b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/DivideServiceImpl.groovy new file mode 100644 index 0000000000..c31c1e8fd6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/DivideServiceImpl.groovy @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +def divide(n1, n2) { + return n1 / n2 +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/MultiplyServiceImpl.py b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/MultiplyServiceImpl.py new file mode 100644 index 0000000000..cfd96f287a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/MultiplyServiceImpl.py @@ -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 multiply(n1, n2): + print "Python Calculator component: multiply(", n1, ",", n2, ")" + return n1 * n2 \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/SubtractServiceImpl.rb b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/SubtractServiceImpl.rb new file mode 100644 index 0000000000..8e7a884d41 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-calculator/src/main/resources/calculator/SubtractServiceImpl.rb @@ -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 subtract(n1, n2) + print "Ruby Calculator subtract(", n1, ",", n2, ")\n" + return n1 - n2 +end \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/README b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/README new file mode 100644 index 0000000000..17b71e7590 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/README @@ -0,0 +1,4 @@ +Spring-bigbank-checkaccount is a part of a spring-bigbank sample. +Please see the Readme file under spring-bigbank to understand how spring-bigbank-checkaccount fits into the overall picture. + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/build.xml new file mode 100644 index 0000000000..26d71c146f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/pom.xml new file mode 100644 index 0000000000..19321adbb6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/pom.xml @@ -0,0 +1,108 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-spring-bigbank-checkaccount + Apache Tuscany SCA Spring-Based BigBank Checking Accounts Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-core-spi + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-spring + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.ws.security + wss4j + 1.5.3 + + + + junit + junit + 4.2 + test + + + + org.apache.activemq + apache-activemq + 4.1.1 + + + org.apache.activemq + activemq-web-demo + + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountDetails.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountDetails.java new file mode 100644 index 0000000000..9737ac27eb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountDetails.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.account.checking; + +/** + * @version $$Rev: 635619 $$ $$Date: 2007-04-09 12:03:34 -0700 (Mon, 09 Apr + * 2007) $$ + */ + +public class CheckingAccountDetails { + 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; + } + + @Override + public String toString() { + return accountNumber + ", balance:" + balance; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountService.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountService.java new file mode 100644 index 0000000000..a8b958010a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountService.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 bigbank.account.checking; + +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +/** + * @version $$Rev: 636465 $$ $$Date: 2008-03-13 00:49:26 +0530 (Thu, 13 Mar 2008) $$ + */ +@Service +@Remotable +public interface CheckingAccountService { + + public CheckingAccountDetails getAccountDetails(String customerID); + + public double deposit(String accountNo, double depositAmt); + + public double withdraw(String accountNo, double withdrawalAmount); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java new file mode 100644 index 0000000000..a18a4920b8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account.checking; + +import java.util.HashMap; +import java.util.Map; + +import org.osoa.sca.annotations.Service; + +/** + * + * */ + +@Service(CheckingAccountService.class) +public class CheckingAccountServiceImpl implements CheckingAccountService { + private Map custAcctMap = new HashMap(); + private Map checkingAccts = new HashMap(); + + public CheckingAccountServiceImpl() { + custAcctMap.put("Customer_01", "CHA_Customer_01"); + custAcctMap.put("Customer_02", "CHA_Customer_02"); + custAcctMap.put("Customer_03", "CHA_Customer_03"); + + checkingAccts.put("CHA_Customer_01", new Double(1000)); + checkingAccts.put("CHA_Customer_02", new Double(1500)); + checkingAccts.put("CHA_Customer_03", new Double(2000)); + } + + public double deposit(String accountNo, double depositAmt) { + checkingAccts.put(accountNo, new Double(checkingAccts.get(accountNo).doubleValue() + depositAmt)); + return checkingAccts.get(accountNo).doubleValue(); + } + + public CheckingAccountDetails getAccountDetails(String customerID) { + CheckingAccountDetails checkingAccount = new CheckingAccountDetails(); + checkingAccount.setAccountNumber(custAcctMap.get(customerID)); + checkingAccount.setBalance(checkingAccts.get(checkingAccount.getAccountNumber()).doubleValue()); + + return checkingAccount; + } + + public double withdraw(String accountNo, double withdrawalAmount) { + double balance = checkingAccts.get(accountNo).doubleValue(); + if ( balance - withdrawalAmount > 0 ) { + balance = balance - withdrawalAmount; + checkingAccts.put(accountNo, balance); + } + return balance; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/server/CheckingAccountServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/server/CheckingAccountServer.java new file mode 100644 index 0000000000..2e367cf32b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/server/CheckingAccountServer.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 bigbank.account.checking.server; + +import java.io.IOException; + +import org.apache.activemq.broker.BrokerService; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; + +/** + * This server program shows how to create an SCA runtime, and start it which + * activates the Spring BigBank CheckingsAccount JMS endpoint. + */ +public class CheckingAccountServer { + + public static void main(String[] args) { + try { + BrokerService jmsBroker; + jmsBroker = new BrokerService(); + jmsBroker.setPersistent(false); + jmsBroker.setUseJmx(false); + jmsBroker.addConnector("tcp://localhost:61619"); + jmsBroker.start(); + + SCANodeFactory factory = SCANodeFactory.newInstance(); + SCANode node = factory.createSCANodeFromClassLoader("CheckingsAccount.composite", CheckingAccountServer.class.getClassLoader()); + node.start(); + + System.out.println("CheckingsAccount server started (press enter to shutdown)"); + System.in.read(); + + node.stop(); + + jmsBroker.stop(); + System.out.println("CheckingsAccount server stopped"); + + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/AccountsDataPasswordCallbackHandler.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/AccountsDataPasswordCallbackHandler.java new file mode 100644 index 0000000000..ad17ab8cf5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/AccountsDataPasswordCallbackHandler.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.account.security; + +import java.io.IOException; + +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.UnsupportedCallbackException; + +import org.apache.ws.security.WSPasswordCallback; + +/** + * Sample userid passwd generation class + */ +public class AccountsDataPasswordCallbackHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + if ( pwcb.getUsage() == WSPasswordCallback.SIGNATURE ) { + System.out.println(" Usage is SIGNATURE ... "); + pwcb.setPassword("bbservice"); + } else if ( pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN ) { + System.out.println("*** Calling ACCOUNTS-DATA Passwd Handler for AUTHENTICATING userID = " + + pwcb.getIdentifer() + " and password = " + pwcb.getPassword() ); + if ( pwcb.getIdentifer().equals("bbaservice") && pwcb.getPassword().equals("bbaservice")) { + System.out.println("AUTHENTICATION SUCCESSFUL!"); + } else { + System.out.println("AUTHENTICATION FAILED!"); + throw new UnsupportedCallbackException(pwcb, "UserId - Password Authentication Failed!"); + } + } + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/BigbankCheckingsAcl.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/BigbankCheckingsAcl.java new file mode 100644 index 0000000000..7b44a28bc9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/BigbankCheckingsAcl.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 bigbank.account.security; + +import java.security.Principal; +import java.util.Hashtable; +import java.util.Map; + +/** + * @version $Rev: 635619 $ $Date: 2008-03-10 23:24:29 +0530 (Mon, 10 Mar 2008) $ + */ +public class BigbankCheckingsAcl { + private static MapcheckingsAcl = new Hashtable(); + + static { + checkingsAcl.put("bbaservice", "Customer_01"); + checkingsAcl.put("bbUser01", "Customer_01"); + } + + + public static void authorize(Principal principal, String resource) { + if ( checkingsAcl.get(principal.getName()) == null || + !checkingsAcl.get(principal.getName()).equals(resource) ) { + throw new RuntimeException("User - " + principal.getName() + " not authorized to access account " + + resource); + } else { + System.out.println("Successfully Authorized '" + principal.getName() + " to access accounts of " + resource); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthImplementationPolicyProvider.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthImplementationPolicyProvider.java new file mode 100644 index 0000000000..bbd5b0c325 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthImplementationPolicyProvider.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 bigbank.account.security; + +import org.apache.tuscany.sca.assembly.ConfiguredOperation; +import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.assembly.OperationsConfigurator; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * @version $Rev: 641726 $ $Date: 2008-03-27 12:54:37 +0530 (Thu, 27 Mar 2008) $ + */ +public class CheckingsDeptAuthImplementationPolicyProvider implements PolicyProvider { + private RuntimeComponent component; + private Implementation implementation; + + public CheckingsDeptAuthImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) { + super(); + this.component = component; + this.implementation = implementation; + } + + private String getContext() { + return "component.implementation: " + component.getURI() + "(" + implementation.getClass().getName() + ")"; + } + + private PolicySet findPolicySet(Operation operation) { + for (PolicySet ps : component.getPolicySets()) { + for (Object p : ps.getPolicies()) { + if (CheckingsDeptAuthPolicy.class.isInstance(p)) { + return ps; + } + } + } + + if ( component instanceof OperationsConfigurator ) { + for ( ConfiguredOperation confOp : ((OperationsConfigurator)component).getConfiguredOperations() ) { + if ( confOp.getName().equals(operation.getName())) { + for (PolicySet ps : confOp.getPolicySets()) { + for (Object p : ps.getPolicies()) { + if (CheckingsDeptAuthPolicy.class.isInstance(p)) { + return ps; + } + } + } + } + } + } + + return null; + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) + */ + public Interceptor createInterceptor(Operation operation) { + PolicySet ps = findPolicySet(operation); + return ps == null ? null : new CheckingsDeptAuthPolicyInterceptor(getContext(), operation, ps); + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase() + */ + public String getPhase() { + return Phase.IMPLEMENTATION_POLICY; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicy.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicy.java new file mode 100644 index 0000000000..cb26ca809d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicy.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 bigbank.account.security; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.policy.Policy; + +/** + * @version $Rev: 641726 $ $Date: 2008-03-27 12:54:37 +0530 (Thu, 27 Mar 2008) $ + */ +public class CheckingsDeptAuthPolicy implements Policy { + + public QName getSchemaName() { + // TODO Auto-generated method stub + return null; + } + + public boolean isUnresolved() { + // TODO Auto-generated method stub + return false; + } + + public void setUnresolved(boolean unresolved) { + // TODO Auto-generated method stub + + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyInterceptor.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyInterceptor.java new file mode 100644 index 0000000000..2ebcc8470a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyInterceptor.java @@ -0,0 +1,71 @@ +package bigbank.account.security; + +import java.security.Principal; + +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.policy.PolicySet; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Policy handler to handle PolicySet related to Logging with the QName + * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy + */ +public class CheckingsDeptAuthPolicyInterceptor implements Interceptor { + private Invoker next; + + public CheckingsDeptAuthPolicyInterceptor(String context, Operation operation, PolicySet policySet) { + super(); + init(); + } + + private final void init() { + } + + public Message invoke(Message msg) { + Object msgBody = msg.getBody(); + if (msgBody instanceof Object[]) { + Object args[] = (Object[])msg.getBody(); + if ( msg.getQoSContext().get(Message.QOS_CTX_SECURITY_PRINCIPAL) != null ) { + BigbankCheckingsAcl.authorize((Principal)msg.getQoSContext().get(Message.QOS_CTX_SECURITY_PRINCIPAL), + (String)args[0]); + } + } + + Message responseMsg = null; + try { + responseMsg = getNext().invoke(msg); + return responseMsg; + } catch (RuntimeException e) { + throw e; + } + } + + public Invoker getNext() { + return next; + } + + public void setNext(Invoker next) { + this.next = next; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyProviderFactory.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyProviderFactory.java new file mode 100644 index 0000000000..24da9878a5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyProviderFactory.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package bigbank.account.security; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.PolicyProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * @version $Rev: 641726 $ $Date: 2008-03-27 12:54:37 +0530 (Thu, 27 Mar 2008) $ + */ +public class CheckingsDeptAuthPolicyProviderFactory implements PolicyProviderFactory { + private ExtensionPointRegistry registry; + + public CheckingsDeptAuthPolicyProviderFactory(ExtensionPointRegistry registry) { + super(); + this.registry = registry; + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createImplementationPolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.assembly.Implementation) + */ + public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) { + return new CheckingsDeptAuthImplementationPolicyProvider(component, implementation); + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createReferencePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentReference, org.apache.tuscany.sca.assembly.Binding) + */ + public PolicyProvider createReferencePolicyProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + return null; + } + + /** + * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createServicePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentService, org.apache.tuscany.sca.assembly.Binding) + */ + public PolicyProvider createServicePolicyProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding) { + return null; + } + + /** + * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType() + */ + public Class getModelType() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyHandler.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyHandler.java new file mode 100644 index 0000000000..5668fa23b9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyHandler.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 bigbank.account.security; + +import java.security.Principal; + +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.util.PolicyHandler; + +/** + * @version $Rev: 635619 $ $Date: 2008-03-10 23:24:29 +0530 (Mon, 10 Mar 2008) $ + */ +public class CheckingsDeptAuthorizationPolicyHandler implements PolicyHandler { + private PolicySet applicablePolicySet = null; + + public void afterInvoke(Object... context) { + } + + public void beforeInvoke(Object... context) { + for ( int count = 0 ; count < context.length ; ++count ) { + if ( context[count] instanceof Message ) { + Message msg = (Message)context[count]; + Object args[] = (Object[])msg.getBody(); + if ( msg.getQoSContext().get(Message.QOS_CTX_SECURITY_PRINCIPAL) != null ) { + BigbankCheckingsAcl.authorize((Principal)msg.getQoSContext().get(Message.QOS_CTX_SECURITY_PRINCIPAL), + (String)args[0]); + } + } + } + } + + public void cleanUp(Object... arg0) { + } + + public PolicySet getApplicablePolicySet() { + return this.applicablePolicySet; + } + + public void setApplicablePolicySet(PolicySet policySet) { + this.applicablePolicySet = policySet; + } + + public void setUp(Object... arg0) { + + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyProcessor.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyProcessor.java new file mode 100644 index 0000000000..96a5b2ca1f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyProcessor.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account.security; + +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.ModelFactoryExtensionPoint; +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; + +/** + * Implementation of a Policy Processor + * + */ +public class CheckingsDeptAuthorizationPolicyProcessor implements StAXArtifactProcessor { + private static final QName CHECKINGS_DEPT_AUTHORIZATION_POLICY_QNAME = new QName("http://bigbank/checkings", "AuthPolicy"); + public QName getArtifactType() { + return CHECKINGS_DEPT_AUTHORIZATION_POLICY_QNAME; + } + + public CheckingsDeptAuthorizationPolicyProcessor(ModelFactoryExtensionPoint modelFactories) { + } + + + public CheckingsDeptAuthPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + CheckingsDeptAuthPolicy policy = new CheckingsDeptAuthPolicy(); + return policy; + } + + public void write(CheckingsDeptAuthPolicy policy, XMLStreamWriter writer) throws ContributionWriteException, + XMLStreamException { + String prefix = "tuscany"; + writer.writeStartElement(prefix, + CHECKINGS_DEPT_AUTHORIZATION_POLICY_QNAME.getLocalPart(), + CHECKINGS_DEPT_AUTHORIZATION_POLICY_QNAME.getNamespaceURI()); + writer.writeNamespace("chk", "http://bigbank/checkings"); + + + writer.writeEndElement(); + } + + public Class getModelType() { + return CheckingsDeptAuthPolicy.class; + } + + public void resolve(CheckingsDeptAuthPolicy arg0, ModelResolver arg1) throws ContributionResolveException { + + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/CheckingsAccount.composite b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/CheckingsAccount.composite new file mode 100644 index 0000000000..371a1afd32 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/CheckingsAccount.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..6491a0d326 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/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 +bigbank.account.security.CheckingsDeptAuthorizationPolicyProcessor;qname=http://bigbank/checkings#AuthPolicy,model=bigbank.account.security.CheckingsDeptAuthPolicy diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler new file mode 100644 index 0000000000..b1bce4339d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# PolicyHandlerClasses to interpret specific PolicyModels against specific QoS infrastructures +# handler classname;qname=;model= +bigbank.account.security.CheckingsDeptAuthorizationPolicyHandler;intent=http://bigbankAccount#authorization,model=bigbank.account.security.CheckingsDeptAuthPolicy diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory new file mode 100644 index 0000000000..d6bfe2167e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the policy extension +bigbank.account.security.CheckingsDeptAuthPolicyProviderFactory;model=bigbank.account.security.CheckingsDeptAuthPolicy \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/definitions.xml b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/definitions.xml new file mode 100644 index 0000000000..d57d02297c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/definitions.xml @@ -0,0 +1,58 @@ + + + + + + + + Authorization Intent + + + + + + + + + UsernameToken + bigbank.account.security.AccountsDataPasswordCallbackHandler + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/spring-context/META-INF/spring/CheckingAccountService-context.xml b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/spring-context/META-INF/spring/CheckingAccountService-context.xml new file mode 100644 index 0000000000..6b2338f611 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-checkaccount/src/main/resources/spring-context/META-INF/spring/CheckingAccountService-context.xml @@ -0,0 +1,33 @@ + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/README b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/README new file mode 100644 index 0000000000..b90bafeb59 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/README @@ -0,0 +1,4 @@ +Spring-bigbank-stockquote is a part of a spring-bigbank sample. +Please see the Readme file under spring-bigbank to understand how spring-bigbank-stockquote fits into the overall picture. + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/build.xml new file mode 100644 index 0000000000..1b38a40495 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/pom.xml new file mode 100644 index 0000000000..97cbc2d329 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/pom.xml @@ -0,0 +1,112 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-spring-bigbank-stockquote + Apache Tuscany SCA Spring-Based BigBank StockQuote Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-spring + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + org.springframework + spring-core + 2.0.8 + + + + org.springframework + spring-beans + 2.0.8 + + + + org.springframework + spring-context + 2.0.8 + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/StockQuoteImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/StockQuoteImpl.java new file mode 100644 index 0000000000..81c47a78d1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/StockQuoteImpl.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.stockquote; + +import org.osoa.sca.annotations.Service; + +/** + * This class implements the StockQuote service. + */ +@Service(StockQuoteService.class) +public class StockQuoteImpl implements StockQuoteService { + + public double getQuote(String symbol) { + double price = 104.0 + Math.random(); + price = ((int)(price * 100)) / 100.0; + + System.out.println("Getting stock quote for: " + symbol + ", value: "+ price); + + return price; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/StockQuoteService.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/StockQuoteService.java new file mode 100644 index 0000000000..d4b3fe9035 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/StockQuoteService.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.stockquote; + +import org.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-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/SCAApplicationContextProvider.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/SCAApplicationContextProvider.java new file mode 100644 index 0000000000..643f9a187c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/SCAApplicationContextProvider.java @@ -0,0 +1,19 @@ +package bigbank.stockquote.server; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; + +public class SCAApplicationContextProvider implements ApplicationContextAware { + + private static ApplicationContext ctx; + + public void setApplicationContext(ApplicationContext appContext) throws BeansException { + // Wiring the ApplicationContext into a static method + ctx = appContext; + } + + public static ApplicationContext getApplicationContext() { + return ctx; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/StockQuoteServer.java b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/StockQuoteServer.java new file mode 100644 index 0000000000..b9abb53eb4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/StockQuoteServer.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.stockquote.server; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.springframework.context.ApplicationContext; + +/** + * This server program shows how to bootstrap SCA from a simple J2SE program + * and start it which activates the StockQuote Web service endpoint. + */ +public class StockQuoteServer { + + public static void main(String[] args) throws Exception { + + System.out.println("Starting the Sample SCA StockQuote Service..."); + + SCANodeFactory factory = SCANodeFactory.newInstance(); + SCANode node = factory.createSCANodeFromClassLoader("StockQuote.composite", StockQuoteServer.class.getClassLoader()); + node.start(); + + // Method 1: To access the Spring Application Context instance + ApplicationContext ctx = SCAApplicationContextProvider.getApplicationContext(); + if (ctx.containsBean("StockQuoteServiceBean")) + System.out.println("StockQuoteServiceBean is now available for use..."); + + System.out.println("Press Enter to Exit..."); + System.in.read(); + + node.stop(); + System.out.println("Bye"); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/resources/META-INF/spring/StockQuoteService-context.xml b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/resources/META-INF/spring/StockQuoteService-context.xml new file mode 100644 index 0000000000..87dd006b5a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/resources/META-INF/spring/StockQuoteService-context.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/resources/StockQuote.composite b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/resources/StockQuote.composite new file mode 100644 index 0000000000..06544c6883 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/spring-bigbank-stockquote/src/main/resources/StockQuote.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/README b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/README new file mode 100644 index 0000000000..46e71bf51e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/README @@ -0,0 +1,28 @@ +Store Sample +====================================== + +This is a sample store scenario that is used as a getting started guide +for Tuscany SCA. For detailed information, please see: + +http://tuscany.apache.org/getting-started-with-tuscany.html + +or + +http://tuscany.apache.org/getting-started-with-tuscany-using-tuscany-eclipse-plugin.html + + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built using Ant as follows: + +cd store +ant compile + +and then, to run: + +ant run + +Once the store application is running use your browser to visit the following +URL: + +http://localhost:8080/store/ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/build.xml new file mode 100644 index 0000000000..652afc3570 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/build.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/cloud.composite b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/cloud.composite new file mode 100644 index 0000000000..7bd13d5b6f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/cloud.composite @@ -0,0 +1,27 @@ + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/domain.composite b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/domain.composite new file mode 100644 index 0000000000..6898c454af --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/domain.composite @@ -0,0 +1,27 @@ + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/pom.xml new file mode 100644 index 0000000000..1cd493807e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/pom.xml @@ -0,0 +1,119 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../pom.xml + + sample-store-distributed + Apache Tuscany SCA Getting Started Online Store Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-launcher + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-domain-manager + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-data-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-widget-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchDomain.java b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchDomain.java new file mode 100644 index 0000000000..dd19f6b49b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchDomain.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 node; + +import org.apache.tuscany.sca.node.launcher.DomainManagerLauncher; + +/** + * 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 LaunchDomain { + public static void main(String[] args) throws Exception { + DomainManagerLauncher.main(args); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchStoreNodeA.java b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchStoreNodeA.java new file mode 100644 index 0000000000..9016e515fb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchStoreNodeA.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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 org.apache.tuscany.sca.node.launcher.NodeLauncher; + +public class LaunchStoreNodeA { + public static void main(String[] args) throws Exception { + NodeLauncher.main(new String[] {"http://localhost:9990/node-config/NodeA"}); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchStoreNodeB.java b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchStoreNodeB.java new file mode 100644 index 0000000000..2b387aec82 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchStoreNodeB.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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 org.apache.tuscany.sca.node.launcher.NodeLauncher; + +public class LaunchStoreNodeB { + public static void main(String[] args) throws Exception { + NodeLauncher.main(new String[] {"http://localhost:9990/node-config/NodeB"}); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchStoreNodeC.java b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchStoreNodeC.java new file mode 100644 index 0000000000..fb138e484f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/node/LaunchStoreNodeC.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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 org.apache.tuscany.sca.node.launcher.NodeLauncher; + +public class LaunchStoreNodeC { + public static void main(String[] args) throws Exception { + NodeLauncher.main(new String[] {"http://localhost:9990/node-config/NodeC"}); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Cart.java b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Cart.java new file mode 100644 index 0000000000..9e6226d963 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Cart.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import org.apache.tuscany.sca.data.collection.Collection; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Cart extends Collection { + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Catalog.java b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Catalog.java new file mode 100644 index 0000000000..2c3b19f579 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Catalog.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Catalog { + Item[] get(); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/CurrencyConverter.java b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/CurrencyConverter.java new file mode 100644 index 0000000000..e104a0423a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/CurrencyConverter.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface CurrencyConverter { + public double getConversion(String fromCurrenycCode, String toCurrencyCode, double amount); + + public String getCurrencySymbol(String currencyCode); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/CurrencyConverterImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/CurrencyConverterImpl.java new file mode 100644 index 0000000000..c354aed447 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/CurrencyConverterImpl.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +public class CurrencyConverterImpl implements CurrencyConverter { + public double getConversion(String fromCurrencyCode, String toCurrencyCode, double amount) { + if (toCurrencyCode.equals("USD")) + return amount; + else if (toCurrencyCode.equals("EUR")) + return ((double)Math.round(amount * 0.7256 * 100)) /100; + return 0; + } + + public String getCurrencySymbol(String currencyCode) { + if (currencyCode.equals("USD")) + return "$"; + else if (currencyCode.equals("EUR")) + return "E"; //"€"; + return "?"; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/FruitsCatalogImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/FruitsCatalogImpl.java new file mode 100644 index 0000000000..377b3d7e59 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/FruitsCatalogImpl.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import java.util.ArrayList; +import java.util.List; + +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; + +public class FruitsCatalogImpl implements Catalog { + + @Property + public String currencyCode = "USD"; + + @Reference + public CurrencyConverter currencyConverter; + + private List catalog = new ArrayList(); + + @Init + public void init() { + String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode); + catalog.add(new Item("Apple", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 2.99))); + catalog.add(new Item("Orange", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 3.55))); + catalog.add(new Item("Pear", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 1.55))); + } + + public Item[] get() { + Item[] catalogArray = new Item[catalog.size()]; + catalog.toArray(catalogArray); + return catalogArray; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Item.java b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Item.java new file mode 100644 index 0000000000..27abd4f016 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Item.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + + +public class Item { + private String name; + private String price; + + public Item() { + } + + public Item(String name, String price) { + this.name = name; + this.price = price; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPrice() { + return price; + } + + public void setPrice(String price) { + this.price = price; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/ShoppingCartImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/ShoppingCartImpl.java new file mode 100644 index 0000000000..9889921a96 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/ShoppingCartImpl.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.tuscany.sca.data.collection.Entry; +import org.apache.tuscany.sca.data.collection.NotFoundException; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; + +@Scope("COMPOSITE") +public class ShoppingCartImpl implements Cart, Total { + + private Map cart; + + @Init + public void init() { + cart = new HashMap(); + } + + public Entry[] getAll() { + Entry[] entries = new Entry[cart.size()]; + int i = 0; + for (Map.Entry e: cart.entrySet()) { + entries[i++] = new Entry(e.getKey(), e.getValue()); + } + return entries; + } + + public Item get(String key) throws NotFoundException { + Item item = cart.get(key); + if (item == null) { + throw new NotFoundException(key); + } else { + return item; + } + } + + public String post(String key, Item item) { + if (key == null) { + key ="cart-" + UUID.randomUUID().toString(); + } + cart.put(key, item); + return key; + } + + public void put(String key, Item item) throws NotFoundException { + if (!cart.containsKey(key)) { + throw new NotFoundException(key); + } + cart.put(key, item); + } + + public void delete(String key) throws NotFoundException { + if (key == null || key.equals("")) { + cart.clear(); + } else { + Item item = cart.remove(key); + if (item == null) + throw new NotFoundException(key); + } + } + + public Entry[] query(String queryString) { + List> entries = new ArrayList>(); + if (queryString.startsWith("name=")) { + String name = queryString.substring(5); + for (Map.Entry e: cart.entrySet()) { + Item item = e.getValue(); + if (item.getName().equals(name)) { + entries.add(new Entry(e.getKey(), e.getValue())); + } + } + } + return entries.toArray(new Entry[entries.size()]); + } + + public String getTotal() { + double total = 0; + String currencySymbol = ""; + if (!cart.isEmpty()) { + Item item = cart.values().iterator().next(); + currencySymbol = item.getPrice().substring(0, 1); + } + for (Item item : cart.values()) { + total += Double.valueOf(item.getPrice().substring(1)); + } + return currencySymbol + String.valueOf(total); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Total.java b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Total.java new file mode 100644 index 0000000000..8f464e526f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/java/services/Total.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Total { + + String getTotal(); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/cloud/NodeA.composite b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/cloud/NodeA.composite new file mode 100644 index 0000000000..f7bfd0fcb6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/cloud/NodeA.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/cloud/NodeB.composite b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/cloud/NodeB.composite new file mode 100644 index 0000000000..187c5caf1c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/cloud/NodeB.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/cloud/NodeC.composite b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/cloud/NodeC.composite new file mode 100644 index 0000000000..98113a3576 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/cloud/NodeC.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..f165ee0e29 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-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-20080910/samples/store-distributed/src/main/resources/nodeA/store.composite b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeA/store.composite new file mode 100644 index 0000000000..2ac608d43f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeA/store.composite @@ -0,0 +1,38 @@ + + + + + + + USD + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..0f8e76ccd7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-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-20080910/samples/store-distributed/src/main/resources/nodeB/store.composite b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeB/store.composite new file mode 100644 index 0000000000..062a7aa2cd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeB/store.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..15bab17c1a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-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-20080910/samples/store-distributed/src/main/resources/nodeC/store.composite b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeC/store.composite new file mode 100644 index 0000000000..5de310128d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeC/store.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeC/uiservices/store.html b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeC/uiservices/store.html new file mode 100644 index 0000000000..45604463d1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/nodeC/uiservices/store.html @@ -0,0 +1,162 @@ + + + +Store + + + + + + + + +

Store

+
+

Catalog

+
+
+
+ +
+ +
+ +

Your Shopping Cart

+
+
+
+
+
+ + + (feed) +
+
+ + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/uiservices/store.html b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/uiservices/store.html new file mode 100644 index 0000000000..45604463d1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/src/main/resources/uiservices/store.html @@ -0,0 +1,162 @@ + + + +Store + + + + + + + + +

Store

+
+

Catalog

+
+
+
+ +
+ +
+ +

Your Shopping Cart

+
+
+
+
+
+ + + (feed) +
+
+ + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/store.png b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/store.png new file mode 100644 index 0000000000..da413edeee Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/store.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/store.svg b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/store.svg new file mode 100644 index 0000000000..74f8ecd36d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/store.svg @@ -0,0 +1,304 @@ + + + + + + + + + + image/svg+xml + + + + + + + + store + ufs + + ShoppingCart + + CurrencyConverter + + + + + + + + + + CurrenyCode HTTP JSONRPC Atom + + Catalog + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/workspace.xml b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/workspace.xml new file mode 100644 index 0000000000..d6cb2bfc81 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store-distributed/workspace.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/README b/sca-java-1.x/branches/sca-java-20080910/samples/store/README new file mode 100644 index 0000000000..46e71bf51e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store/README @@ -0,0 +1,28 @@ +Store Sample +====================================== + +This is a sample store scenario that is used as a getting started guide +for Tuscany SCA. For detailed information, please see: + +http://tuscany.apache.org/getting-started-with-tuscany.html + +or + +http://tuscany.apache.org/getting-started-with-tuscany-using-tuscany-eclipse-plugin.html + + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built using Ant as follows: + +cd store +ant compile + +and then, to run: + +ant run + +Once the store application is running use your browser to visit the following +URL: + +http://localhost:8080/store/ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/store/build.xml new file mode 100644 index 0000000000..652afc3570 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store/build.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/store/pom.xml new file mode 100644 index 0000000000..ce00e13bb5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store/pom.xml @@ -0,0 +1,106 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../pom.xml + + sample-store + Apache Tuscany SCA Getting Started Online Store Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-data-api + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-widget-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/launch/Launch.java b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/launch/Launch.java new file mode 100644 index 0000000000..801697abea --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/launch/Launch.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 launch; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class Launch { + public static void main(String[] args) throws Exception { + System.out.println("Starting ..."); + SCADomain scaDomain = SCADomain.newInstance("store.composite"); + System.out.println("store.composite ready for big business !!!"); + System.in.read(); + System.out.println("Stopping ..."); + scaDomain.close(); + System.out.println(); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Cart.java b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Cart.java new file mode 100644 index 0000000000..9e6226d963 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Cart.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import org.apache.tuscany.sca.data.collection.Collection; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Cart extends Collection { + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Catalog.java b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Catalog.java new file mode 100644 index 0000000000..2c3b19f579 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Catalog.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Catalog { + Item[] get(); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/CurrencyConverter.java b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/CurrencyConverter.java new file mode 100644 index 0000000000..e104a0423a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/CurrencyConverter.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface CurrencyConverter { + public double getConversion(String fromCurrenycCode, String toCurrencyCode, double amount); + + public String getCurrencySymbol(String currencyCode); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/CurrencyConverterImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/CurrencyConverterImpl.java new file mode 100644 index 0000000000..c354aed447 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/CurrencyConverterImpl.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +public class CurrencyConverterImpl implements CurrencyConverter { + public double getConversion(String fromCurrencyCode, String toCurrencyCode, double amount) { + if (toCurrencyCode.equals("USD")) + return amount; + else if (toCurrencyCode.equals("EUR")) + return ((double)Math.round(amount * 0.7256 * 100)) /100; + return 0; + } + + public String getCurrencySymbol(String currencyCode) { + if (currencyCode.equals("USD")) + return "$"; + else if (currencyCode.equals("EUR")) + return "E"; //"€"; + return "?"; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/FruitsCatalogImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/FruitsCatalogImpl.java new file mode 100644 index 0000000000..377b3d7e59 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/FruitsCatalogImpl.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import java.util.ArrayList; +import java.util.List; + +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; + +public class FruitsCatalogImpl implements Catalog { + + @Property + public String currencyCode = "USD"; + + @Reference + public CurrencyConverter currencyConverter; + + private List catalog = new ArrayList(); + + @Init + public void init() { + String currencySymbol = currencyConverter.getCurrencySymbol(currencyCode); + catalog.add(new Item("Apple", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 2.99))); + catalog.add(new Item("Orange", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 3.55))); + catalog.add(new Item("Pear", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 1.55))); + } + + public Item[] get() { + Item[] catalogArray = new Item[catalog.size()]; + catalog.toArray(catalogArray); + return catalogArray; + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Item.java b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Item.java new file mode 100644 index 0000000000..27abd4f016 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Item.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + + +public class Item { + private String name; + private String price; + + public Item() { + } + + public Item(String name, String price) { + this.name = name; + this.price = price; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPrice() { + return price; + } + + public void setPrice(String price) { + this.price = price; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/ShoppingCartImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/ShoppingCartImpl.java new file mode 100644 index 0000000000..9889921a96 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/ShoppingCartImpl.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.tuscany.sca.data.collection.Entry; +import org.apache.tuscany.sca.data.collection.NotFoundException; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; + +@Scope("COMPOSITE") +public class ShoppingCartImpl implements Cart, Total { + + private Map cart; + + @Init + public void init() { + cart = new HashMap(); + } + + public Entry[] getAll() { + Entry[] entries = new Entry[cart.size()]; + int i = 0; + for (Map.Entry e: cart.entrySet()) { + entries[i++] = new Entry(e.getKey(), e.getValue()); + } + return entries; + } + + public Item get(String key) throws NotFoundException { + Item item = cart.get(key); + if (item == null) { + throw new NotFoundException(key); + } else { + return item; + } + } + + public String post(String key, Item item) { + if (key == null) { + key ="cart-" + UUID.randomUUID().toString(); + } + cart.put(key, item); + return key; + } + + public void put(String key, Item item) throws NotFoundException { + if (!cart.containsKey(key)) { + throw new NotFoundException(key); + } + cart.put(key, item); + } + + public void delete(String key) throws NotFoundException { + if (key == null || key.equals("")) { + cart.clear(); + } else { + Item item = cart.remove(key); + if (item == null) + throw new NotFoundException(key); + } + } + + public Entry[] query(String queryString) { + List> entries = new ArrayList>(); + if (queryString.startsWith("name=")) { + String name = queryString.substring(5); + for (Map.Entry e: cart.entrySet()) { + Item item = e.getValue(); + if (item.getName().equals(name)) { + entries.add(new Entry(e.getKey(), e.getValue())); + } + } + } + return entries.toArray(new Entry[entries.size()]); + } + + public String getTotal() { + double total = 0; + String currencySymbol = ""; + if (!cart.isEmpty()) { + Item item = cart.values().iterator().next(); + currencySymbol = item.getPrice().substring(0, 1); + } + for (Item item : cart.values()) { + total += Double.valueOf(item.getPrice().substring(1)); + } + return currencySymbol + String.valueOf(total); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Total.java b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Total.java new file mode 100644 index 0000000000..8f464e526f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/java/services/Total.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package services; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Total { + + String getTotal(); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/resources/store.composite b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/resources/store.composite new file mode 100644 index 0000000000..571678839d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/resources/store.composite @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/resources/uiservices/store.html b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/resources/uiservices/store.html new file mode 100644 index 0000000000..45604463d1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store/src/main/resources/uiservices/store.html @@ -0,0 +1,162 @@ + + + +Store + + + + + + + + +

Store

+
+

Catalog

+
+
+
+ +
+ +
+ +

Your Shopping Cart

+
+
+
+
+
+ + + (feed) +
+
+ + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/store.png b/sca-java-1.x/branches/sca-java-20080910/samples/store/store.png new file mode 100644 index 0000000000..da413edeee Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/store/store.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/store/store.svg b/sca-java-1.x/branches/sca-java-20080910/samples/store/store.svg new file mode 100644 index 0000000000..74f8ecd36d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/store/store.svg @@ -0,0 +1,304 @@ + + + + + + + + + + image/svg+xml + + + + + + + + store + ufs + + ShoppingCart + + CurrencyConverter + + + + + + + + + + CurrenyCode HTTP JSONRPC Atom + + Catalog + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/supplychain/README b/sca-java-1.x/branches/sca-java-20080910/samples/supplychain/README new file mode 100644 index 0000000000..ea4493fdd4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/supplychain/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/supplychain/build.xml new file mode 100644 index 0000000000..506180b8b1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/supplychain/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/supplychain/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/supplychain/pom.xml new file mode 100644 index 0000000000..0b5a76be4c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/supplychain/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-supplychain + Apache Tuscany SCA Supply Chain Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/supplychain/src/main/java/supplychain/Customer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/supplychain/src/main/java/supplychain/CustomerComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/supplychain/src/main/java/supplychain/Retailer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/supplychain/src/main/java/supplychain/RetailerComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/supplychain/src/main/java/supplychain/Shipper.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/supplychain/src/main/java/supplychain/ShipperComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/supplychain/src/main/java/supplychain/SupplyChainClient.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/supplychain/src/main/java/supplychain/Warehouse.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/supplychain/src/main/java/supplychain/WarehouseComponentImpl.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/supplychain/src/main/resources/supplychain.composite b/sca-java-1.x/branches/sca-java-20080910/samples/supplychain/src/main/resources/supplychain.composite new file mode 100644 index 0000000000..301efcaf1f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/supplychain/src/main/resources/supplychain.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/supplychain/supplychain.png b/sca-java-1.x/branches/sca-java-20080910/samples/supplychain/supplychain.png new file mode 100644 index 0000000000..51a384e827 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/supplychain/supplychain.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/supplychain/supplychain.svg b/sca-java-1.x/branches/sca-java-20080910/samples/supplychain/supplychain.svg new file mode 100644 index 0000000000..f72e77acab --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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-20080910/samples/web-resource/README b/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/README new file mode 100644 index 0000000000..56bffba6a3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/README @@ -0,0 +1,76 @@ +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] 14-Jan-2008 14:28:07 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:8080/myWeb/* + [java] Sample server started (press enter to shutdown) + [java] + [java] To get the Web resource, point your Web browser to the following add +ress: + [java] http://localhost:8080/myWeb/index.html + [java] + +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-20080910/samples/web-resource/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/build.xml new file mode 100644 index 0000000000..5f6b6091e7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/pom.xml new file mode 100644 index 0000000000..8c3f8d894c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-web-resource + Apache Tuscany SCA Web Resource Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-resource-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/src/main/java/web/resource/SampleServer.java b/sca-java-1.x/branches/sca-java-20080910/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-20080910/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-20080910/samples/web-resource/src/main/resources/WebResource.composite b/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/src/main/resources/WebResource.composite new file mode 100644 index 0000000000..4536136a8b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/src/main/resources/WebResource.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/src/main/resources/myContent/index.html b/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/src/main/resources/myContent/index.html new file mode 100644 index 0000000000..55de048373 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/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">
+    <implementation.resource location="myContent"/>
+    <service name="Resource">
+      <binding.http/>
+    </service>
+  </component>      
+
+</composite>
+  	
+ + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/web-resource.png b/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/web-resource.png new file mode 100644 index 0000000000..7259447b65 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/web-resource.png differ diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/web-resource.svg b/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/web-resource.svg new file mode 100644 index 0000000000..0d1257316c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/web-resource/web-resource.svg @@ -0,0 +1,197 @@ + + + + + + + + + + image/svg+xml + + + + + + + + WebResource + + + myWeb + implementation.resource + + File System + ./myContent /index.html + + binding.http + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/LICENSE b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/LICENSE @@ -0,0 +1,205 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/NOTICE b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/NOTICE new file mode 100644 index 0000000000..1325efd8bf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/README b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/README new file mode 100644 index 0000000000..12f81543f0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/README @@ -0,0 +1,72 @@ +ZipCode JAX-WS Sample +====================================== +This sample demonstrates how to access an existing web service using JAX-WS/JAXB generated java interfaces/classes. + +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-zipcode-jaxws.jar zipcode.ZipCodeClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-zipcode-jaxws.jar zipcode.ZipCodeClient + + +Sample Overview +--------------- +The sample provides a single component exposing a Web resource. + +zipcode-jaxws/ + src/ + main/ + java/ + + resources/ + ZipCode.composite - the SCA assembly for this sample + zipcode-jaxws.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 zipcode-jaxws +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] 14-Jan-2008 14:28:07 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:8080/myWeb/* + [java] Sample server started (press enter to shutdown) + [java] + [java] To get the Web resource, point your Web browser to the following add +ress: + [java] http://localhost:8080/myWeb/index.html + [java] + +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 zipcode-jaxws +mvn + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/build.xml b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/build.xml new file mode 100644 index 0000000000..85caf5954e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/build.xml @@ -0,0 +1,68 @@ + + +]> + + + &buildDependency; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/pom.xml b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/pom.xml new file mode 100644 index 0000000000..eace7b1bfe --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/pom.xml @@ -0,0 +1,245 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-zipcode-jaxws + jar + Apache Tuscany SCA US Zip Code JAX-WS Sample + Apache Tuscany SCA US Zip Code JAX-WS Sample + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.4-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + + java.net + java.net Maven 1.x Repository + http://download.java.net/maven/1 + legacy + + + java.net2 + java.net Maven 2.x Repository + http://download.java.net/maven/2 + + + + + + java.net2 + java.net Maven 2.x Repository + http://download.java.net/maven/2 + + + + + + ${artifactId} + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.1 + + + + install-wsdl + validate + + run + + + + + + + + + + + + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + location.LocationClient + true + + + generate + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + -Djava.endorsed.dirs=target/endorsed + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy + generate-sources + + copy + + + + + javax.xml.ws + jaxws-api + 2.1 + jar + + + javax.xml.bind + jaxb-api + 2.1 + jar + + + ${project.build.directory}/endorsed + false + true + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByAreaCode.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByAreaCode.java new file mode 100644 index 0000000000..8c9a48bf40 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByAreaCode.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 com.example.uszip; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

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

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="USAreaCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "usAreaCode" +}) +@XmlRootElement(name = "GetInfoByAreaCode") +public class GetInfoByAreaCode { + + @XmlElement(name = "USAreaCode") + protected String usAreaCode; + + /** + * Gets the value of the usAreaCode property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getUSAreaCode() { + return usAreaCode; + } + + /** + * Sets the value of the usAreaCode property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setUSAreaCode(String value) { + this.usAreaCode = value; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByAreaCodeResponse.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByAreaCodeResponse.java new file mode 100644 index 0000000000..93847c8809 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByAreaCodeResponse.java @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.example.uszip; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlMixed; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

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

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="GetInfoByAreaCodeResult" minOccurs="0">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <any/>
+ *                 </sequence>
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "getInfoByAreaCodeResult" +}) +@XmlRootElement(name = "GetInfoByAreaCodeResponse") +public class GetInfoByAreaCodeResponse { + + @XmlElement(name = "GetInfoByAreaCodeResult") + protected GetInfoByAreaCodeResponse.GetInfoByAreaCodeResult getInfoByAreaCodeResult; + + /** + * Gets the value of the getInfoByAreaCodeResult property. + * + * @return + * possible object is + * {@link GetInfoByAreaCodeResponse.GetInfoByAreaCodeResult } + * + */ + public GetInfoByAreaCodeResponse.GetInfoByAreaCodeResult getGetInfoByAreaCodeResult() { + return getInfoByAreaCodeResult; + } + + /** + * Sets the value of the getInfoByAreaCodeResult property. + * + * @param value + * allowed object is + * {@link GetInfoByAreaCodeResponse.GetInfoByAreaCodeResult } + * + */ + public void setGetInfoByAreaCodeResult(GetInfoByAreaCodeResponse.GetInfoByAreaCodeResult value) { + this.getInfoByAreaCodeResult = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

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

+     * <complexType>
+     *   <complexContent>
+     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *       <sequence>
+     *         <any/>
+     *       </sequence>
+     *     </restriction>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "content" + }) + public static class GetInfoByAreaCodeResult { + + @XmlMixed + @XmlAnyElement(lax = true) + protected List content; + + /** + * Gets the value of the content property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the content property. + * + *

+ * For example, to add a new item, do as follows: + *

+         *    getContent().add(newItem);
+         * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * {@link Object } + * + * + */ + public List getContent() { + if (content == null) { + content = new ArrayList(); + } + return this.content; + } + + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByCity.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByCity.java new file mode 100644 index 0000000000..cf9276d417 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByCity.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 com.example.uszip; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

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

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="USCity" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "usCity" +}) +@XmlRootElement(name = "GetInfoByCity") +public class GetInfoByCity { + + @XmlElement(name = "USCity") + protected String usCity; + + /** + * Gets the value of the usCity property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getUSCity() { + return usCity; + } + + /** + * Sets the value of the usCity property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setUSCity(String value) { + this.usCity = value; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByCityResponse.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByCityResponse.java new file mode 100644 index 0000000000..9dc0e41b2b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByCityResponse.java @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.example.uszip; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlMixed; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

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

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="GetInfoByCityResult" minOccurs="0">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <any/>
+ *                 </sequence>
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "getInfoByCityResult" +}) +@XmlRootElement(name = "GetInfoByCityResponse") +public class GetInfoByCityResponse { + + @XmlElement(name = "GetInfoByCityResult") + protected GetInfoByCityResponse.GetInfoByCityResult getInfoByCityResult; + + /** + * Gets the value of the getInfoByCityResult property. + * + * @return + * possible object is + * {@link GetInfoByCityResponse.GetInfoByCityResult } + * + */ + public GetInfoByCityResponse.GetInfoByCityResult getGetInfoByCityResult() { + return getInfoByCityResult; + } + + /** + * Sets the value of the getInfoByCityResult property. + * + * @param value + * allowed object is + * {@link GetInfoByCityResponse.GetInfoByCityResult } + * + */ + public void setGetInfoByCityResult(GetInfoByCityResponse.GetInfoByCityResult value) { + this.getInfoByCityResult = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

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

+     * <complexType>
+     *   <complexContent>
+     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *       <sequence>
+     *         <any/>
+     *       </sequence>
+     *     </restriction>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "content" + }) + public static class GetInfoByCityResult { + + @XmlMixed + @XmlAnyElement(lax = true) + protected List content; + + /** + * Gets the value of the content property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the content property. + * + *

+ * For example, to add a new item, do as follows: + *

+         *    getContent().add(newItem);
+         * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * {@link Object } + * + * + */ + public List getContent() { + if (content == null) { + content = new ArrayList(); + } + return this.content; + } + + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByState.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByState.java new file mode 100644 index 0000000000..48be94b14a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByState.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 com.example.uszip; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

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

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="USState" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "usState" +}) +@XmlRootElement(name = "GetInfoByState") +public class GetInfoByState { + + @XmlElement(name = "USState") + protected String usState; + + /** + * Gets the value of the usState property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getUSState() { + return usState; + } + + /** + * Sets the value of the usState property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setUSState(String value) { + this.usState = value; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByStateResponse.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByStateResponse.java new file mode 100644 index 0000000000..1645e11ca2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByStateResponse.java @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.example.uszip; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlMixed; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

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

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="GetInfoByStateResult" minOccurs="0">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <any/>
+ *                 </sequence>
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "getInfoByStateResult" +}) +@XmlRootElement(name = "GetInfoByStateResponse") +public class GetInfoByStateResponse { + + @XmlElement(name = "GetInfoByStateResult") + protected GetInfoByStateResponse.GetInfoByStateResult getInfoByStateResult; + + /** + * Gets the value of the getInfoByStateResult property. + * + * @return + * possible object is + * {@link GetInfoByStateResponse.GetInfoByStateResult } + * + */ + public GetInfoByStateResponse.GetInfoByStateResult getGetInfoByStateResult() { + return getInfoByStateResult; + } + + /** + * Sets the value of the getInfoByStateResult property. + * + * @param value + * allowed object is + * {@link GetInfoByStateResponse.GetInfoByStateResult } + * + */ + public void setGetInfoByStateResult(GetInfoByStateResponse.GetInfoByStateResult value) { + this.getInfoByStateResult = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

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

+     * <complexType>
+     *   <complexContent>
+     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *       <sequence>
+     *         <any/>
+     *       </sequence>
+     *     </restriction>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "content" + }) + public static class GetInfoByStateResult { + + @XmlMixed + @XmlAnyElement(lax = true) + protected List content; + + /** + * Gets the value of the content property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the content property. + * + *

+ * For example, to add a new item, do as follows: + *

+         *    getContent().add(newItem);
+         * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * {@link Object } + * + * + */ + public List getContent() { + if (content == null) { + content = new ArrayList(); + } + return this.content; + } + + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByZIP.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByZIP.java new file mode 100644 index 0000000000..45c948b4b4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByZIP.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 com.example.uszip; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

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

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="USZip" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "usZip" +}) +@XmlRootElement(name = "GetInfoByZIP") +public class GetInfoByZIP { + + @XmlElement(name = "USZip") + protected String usZip; + + /** + * Gets the value of the usZip property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getUSZip() { + return usZip; + } + + /** + * Sets the value of the usZip property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setUSZip(String value) { + this.usZip = value; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByZIPResponse.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByZIPResponse.java new file mode 100644 index 0000000000..9e78dc6d0a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/GetInfoByZIPResponse.java @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.example.uszip; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlMixed; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

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

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="GetInfoByZIPResult" minOccurs="0">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <any/>
+ *                 </sequence>
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "getInfoByZIPResult" +}) +@XmlRootElement(name = "GetInfoByZIPResponse") +public class GetInfoByZIPResponse { + + @XmlElement(name = "GetInfoByZIPResult") + protected GetInfoByZIPResponse.GetInfoByZIPResult getInfoByZIPResult; + + /** + * Gets the value of the getInfoByZIPResult property. + * + * @return + * possible object is + * {@link GetInfoByZIPResponse.GetInfoByZIPResult } + * + */ + public GetInfoByZIPResponse.GetInfoByZIPResult getGetInfoByZIPResult() { + return getInfoByZIPResult; + } + + /** + * Sets the value of the getInfoByZIPResult property. + * + * @param value + * allowed object is + * {@link GetInfoByZIPResponse.GetInfoByZIPResult } + * + */ + public void setGetInfoByZIPResult(GetInfoByZIPResponse.GetInfoByZIPResult value) { + this.getInfoByZIPResult = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

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

+     * <complexType>
+     *   <complexContent>
+     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *       <sequence>
+     *         <any/>
+     *       </sequence>
+     *     </restriction>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "content" + }) + public static class GetInfoByZIPResult { + + @XmlMixed + @XmlAnyElement(lax = true) + protected List content; + + /** + * Gets the value of the content property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the content property. + * + *

+ * For example, to add a new item, do as follows: + *

+         *    getContent().add(newItem);
+         * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * {@link Object } + * + * + */ + public List getContent() { + if (content == null) { + content = new ArrayList(); + } + return this.content; + } + + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/ObjectFactory.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/ObjectFactory.java new file mode 100644 index 0000000000..ced83ff09a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/ObjectFactory.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 com.example.uszip; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.example.uszip package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.example.uszip + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link GetInfoByCity } + * + */ + public GetInfoByCity createGetInfoByCity() { + return new GetInfoByCity(); + } + + /** + * Create an instance of {@link GetInfoByState } + * + */ + public GetInfoByState createGetInfoByState() { + return new GetInfoByState(); + } + + /** + * Create an instance of {@link GetInfoByZIPResponse.GetInfoByZIPResult } + * + */ + public GetInfoByZIPResponse.GetInfoByZIPResult createGetInfoByZIPResponseGetInfoByZIPResult() { + return new GetInfoByZIPResponse.GetInfoByZIPResult(); + } + + /** + * Create an instance of {@link GetInfoByStateResponse.GetInfoByStateResult } + * + */ + public GetInfoByStateResponse.GetInfoByStateResult createGetInfoByStateResponseGetInfoByStateResult() { + return new GetInfoByStateResponse.GetInfoByStateResult(); + } + + /** + * Create an instance of {@link GetInfoByAreaCodeResponse.GetInfoByAreaCodeResult } + * + */ + public GetInfoByAreaCodeResponse.GetInfoByAreaCodeResult createGetInfoByAreaCodeResponseGetInfoByAreaCodeResult() { + return new GetInfoByAreaCodeResponse.GetInfoByAreaCodeResult(); + } + + /** + * Create an instance of {@link GetInfoByZIP } + * + */ + public GetInfoByZIP createGetInfoByZIP() { + return new GetInfoByZIP(); + } + + /** + * Create an instance of {@link GetInfoByAreaCodeResponse } + * + */ + public GetInfoByAreaCodeResponse createGetInfoByAreaCodeResponse() { + return new GetInfoByAreaCodeResponse(); + } + + /** + * Create an instance of {@link GetInfoByCityResponse } + * + */ + public GetInfoByCityResponse createGetInfoByCityResponse() { + return new GetInfoByCityResponse(); + } + + /** + * Create an instance of {@link GetInfoByStateResponse } + * + */ + public GetInfoByStateResponse createGetInfoByStateResponse() { + return new GetInfoByStateResponse(); + } + + /** + * Create an instance of {@link GetInfoByCityResponse.GetInfoByCityResult } + * + */ + public GetInfoByCityResponse.GetInfoByCityResult createGetInfoByCityResponseGetInfoByCityResult() { + return new GetInfoByCityResponse.GetInfoByCityResult(); + } + + /** + * Create an instance of {@link GetInfoByZIPResponse } + * + */ + public GetInfoByZIPResponse createGetInfoByZIPResponse() { + return new GetInfoByZIPResponse(); + } + + /** + * Create an instance of {@link GetInfoByAreaCode } + * + */ + public GetInfoByAreaCode createGetInfoByAreaCode() { + return new GetInfoByAreaCode(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/USZip.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/USZip.java new file mode 100644 index 0000000000..22493ba9b8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/USZip.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.example.uszip; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.logging.Logger; + +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import javax.xml.ws.WebEndpoint; +import javax.xml.ws.WebServiceClient; +import javax.xml.ws.WebServiceFeature; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.1.3-b02- + * Generated source version: 2.1 + * + */ +@WebServiceClient(name = "USZip", targetNamespace = "http://www.webserviceX.NET", wsdlLocation = "file:/C:/Tuscany/java/sca/demos/us-location/src/main/resources/wsdl/uszip.wsdl") +public class USZip + extends Service +{ + + private final static URL USZIP_WSDL_LOCATION; + private final static Logger logger = Logger.getLogger(com.example.uszip.USZip.class.getName()); + + static { + URL url = null; + try { + URL baseUrl; + baseUrl = com.example.uszip.USZip.class.getResource("."); + url = new URL(baseUrl, "file:/C:/Tuscany/java/sca/demos/us-location/src/main/resources/wsdl/uszip.wsdl"); + } catch (MalformedURLException e) { + logger.warning("Failed to create URL for the wsdl Location: 'file:/C:/Tuscany/java/sca/demos/us-location/src/main/resources/wsdl/uszip.wsdl', retrying as a local file"); + logger.warning(e.getMessage()); + } + USZIP_WSDL_LOCATION = url; + } + + public USZip(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + + public USZip() { + super(USZIP_WSDL_LOCATION, new QName("http://www.webserviceX.NET", "USZip")); + } + + /** + * + * @return + * returns USZipSoap + */ + @WebEndpoint(name = "USZipSoap") + public USZipSoap getUSZipSoap() { + return super.getPort(new QName("http://www.webserviceX.NET", "USZipSoap"), USZipSoap.class); + } + + /** + * + * @param features + * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. + * @return + * returns USZipSoap + */ + @WebEndpoint(name = "USZipSoap") + public USZipSoap getUSZipSoap(WebServiceFeature... features) { + return super.getPort(new QName("http://www.webserviceX.NET", "USZipSoap"), USZipSoap.class, features); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/USZipSoap.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/USZipSoap.java new file mode 100644 index 0000000000..5ac370005f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/USZipSoap.java @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.example.uszip; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.1.3-b02- + * Generated source version: 2.1 + * + */ +@WebService(name = "USZipSoap", targetNamespace = "http://www.webserviceX.NET") +@XmlSeeAlso({ + ObjectFactory.class +}) +public interface USZipSoap { + + + /** + * Get State Code,City,Area Code,Time Zone,Zip Code by Zip Code + * + * @param usZip + * @return + * returns com.example.uszip.GetInfoByZIPResponse.GetInfoByZIPResult + */ + @WebMethod(operationName = "GetInfoByZIP", action = "http://www.webserviceX.NET/GetInfoByZIP") + @WebResult(name = "GetInfoByZIPResult", targetNamespace = "http://www.webserviceX.NET") + @RequestWrapper(localName = "GetInfoByZIP", targetNamespace = "http://www.webserviceX.NET", className = "com.example.uszip.GetInfoByZIP") + @ResponseWrapper(localName = "GetInfoByZIPResponse", targetNamespace = "http://www.webserviceX.NET", className = "com.example.uszip.GetInfoByZIPResponse") + public com.example.uszip.GetInfoByZIPResponse.GetInfoByZIPResult getInfoByZIP( + @WebParam(name = "USZip", targetNamespace = "http://www.webserviceX.NET") + String usZip); + + /** + * Get State Code,City,Area Code,Time Zone,Zip Code by City + * + * @param usCity + * @return + * returns com.example.uszip.GetInfoByCityResponse.GetInfoByCityResult + */ + @WebMethod(operationName = "GetInfoByCity", action = "http://www.webserviceX.NET/GetInfoByCity") + @WebResult(name = "GetInfoByCityResult", targetNamespace = "http://www.webserviceX.NET") + @RequestWrapper(localName = "GetInfoByCity", targetNamespace = "http://www.webserviceX.NET", className = "com.example.uszip.GetInfoByCity") + @ResponseWrapper(localName = "GetInfoByCityResponse", targetNamespace = "http://www.webserviceX.NET", className = "com.example.uszip.GetInfoByCityResponse") + public com.example.uszip.GetInfoByCityResponse.GetInfoByCityResult getInfoByCity( + @WebParam(name = "USCity", targetNamespace = "http://www.webserviceX.NET") + String usCity); + + /** + * Get State Code,City,Area Code,Time Zone,Zip Code by state + * + * @param usState + * @return + * returns com.example.uszip.GetInfoByStateResponse.GetInfoByStateResult + */ + @WebMethod(operationName = "GetInfoByState", action = "http://www.webserviceX.NET/GetInfoByState") + @WebResult(name = "GetInfoByStateResult", targetNamespace = "http://www.webserviceX.NET") + @RequestWrapper(localName = "GetInfoByState", targetNamespace = "http://www.webserviceX.NET", className = "com.example.uszip.GetInfoByState") + @ResponseWrapper(localName = "GetInfoByStateResponse", targetNamespace = "http://www.webserviceX.NET", className = "com.example.uszip.GetInfoByStateResponse") + public com.example.uszip.GetInfoByStateResponse.GetInfoByStateResult getInfoByState( + @WebParam(name = "USState", targetNamespace = "http://www.webserviceX.NET") + String usState); + + /** + * Get State Code,City,Area Code,Time Zone,Zip Code by Area Code + * + * @param usAreaCode + * @return + * returns com.example.uszip.GetInfoByAreaCodeResponse.GetInfoByAreaCodeResult + */ + @WebMethod(operationName = "GetInfoByAreaCode", action = "http://www.webserviceX.NET/GetInfoByAreaCode") + @WebResult(name = "GetInfoByAreaCodeResult", targetNamespace = "http://www.webserviceX.NET") + @RequestWrapper(localName = "GetInfoByAreaCode", targetNamespace = "http://www.webserviceX.NET", className = "com.example.uszip.GetInfoByAreaCode") + @ResponseWrapper(localName = "GetInfoByAreaCodeResponse", targetNamespace = "http://www.webserviceX.NET", className = "com.example.uszip.GetInfoByAreaCodeResponse") + public com.example.uszip.GetInfoByAreaCodeResponse.GetInfoByAreaCodeResult getInfoByAreaCode( + @WebParam(name = "USAreaCode", targetNamespace = "http://www.webserviceX.NET") + String usAreaCode); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/package-info.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/package-info.java new file mode 100644 index 0000000000..d120f34ee5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/uszip/package-info.java @@ -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. + */ +@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.webserviceX.NET", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package com.example.uszip; diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/ArrayOfWeatherData.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/ArrayOfWeatherData.java new file mode 100644 index 0000000000..5385fb57be --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/ArrayOfWeatherData.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 com.example.weather; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for ArrayOfWeatherData complex type. + * + *

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

+ * <complexType name="ArrayOfWeatherData">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="WeatherData" type="{http://www.webservicex.net}WeatherData" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ArrayOfWeatherData", propOrder = { + "weatherData" +}) +public class ArrayOfWeatherData { + + @XmlElement(name = "WeatherData") + protected List weatherData; + + /** + * Gets the value of the weatherData property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the weatherData property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getWeatherData().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link WeatherData } + * + * + */ + public List getWeatherData() { + if (weatherData == null) { + weatherData = new ArrayList(); + } + return this.weatherData; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByPlaceName.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByPlaceName.java new file mode 100644 index 0000000000..9eb205e75d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByPlaceName.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 com.example.weather; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

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

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="PlaceName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "placeName" +}) +@XmlRootElement(name = "GetWeatherByPlaceName") +public class GetWeatherByPlaceName { + + @XmlElement(name = "PlaceName") + protected String placeName; + + /** + * Gets the value of the placeName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPlaceName() { + return placeName; + } + + /** + * Sets the value of the placeName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPlaceName(String value) { + this.placeName = value; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByPlaceNameResponse.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByPlaceNameResponse.java new file mode 100644 index 0000000000..e281509623 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByPlaceNameResponse.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 com.example.weather; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

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

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="GetWeatherByPlaceNameResult" type="{http://www.webservicex.net}WeatherForecasts"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "getWeatherByPlaceNameResult" +}) +@XmlRootElement(name = "GetWeatherByPlaceNameResponse") +public class GetWeatherByPlaceNameResponse { + + @XmlElement(name = "GetWeatherByPlaceNameResult", required = true) + protected WeatherForecasts getWeatherByPlaceNameResult; + + /** + * Gets the value of the getWeatherByPlaceNameResult property. + * + * @return + * possible object is + * {@link WeatherForecasts } + * + */ + public WeatherForecasts getGetWeatherByPlaceNameResult() { + return getWeatherByPlaceNameResult; + } + + /** + * Sets the value of the getWeatherByPlaceNameResult property. + * + * @param value + * allowed object is + * {@link WeatherForecasts } + * + */ + public void setGetWeatherByPlaceNameResult(WeatherForecasts value) { + this.getWeatherByPlaceNameResult = value; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByZipCode.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByZipCode.java new file mode 100644 index 0000000000..08d4a70364 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByZipCode.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 com.example.weather; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

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

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="ZipCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "zipCode" +}) +@XmlRootElement(name = "GetWeatherByZipCode") +public class GetWeatherByZipCode { + + @XmlElement(name = "ZipCode") + protected String zipCode; + + /** + * Gets the value of the zipCode property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getZipCode() { + return zipCode; + } + + /** + * Sets the value of the zipCode property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setZipCode(String value) { + this.zipCode = value; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByZipCodeResponse.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByZipCodeResponse.java new file mode 100644 index 0000000000..9288f5332e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/GetWeatherByZipCodeResponse.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 com.example.weather; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

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

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="GetWeatherByZipCodeResult" type="{http://www.webservicex.net}WeatherForecasts"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "getWeatherByZipCodeResult" +}) +@XmlRootElement(name = "GetWeatherByZipCodeResponse") +public class GetWeatherByZipCodeResponse { + + @XmlElement(name = "GetWeatherByZipCodeResult", required = true) + protected WeatherForecasts getWeatherByZipCodeResult; + + /** + * Gets the value of the getWeatherByZipCodeResult property. + * + * @return + * possible object is + * {@link WeatherForecasts } + * + */ + public WeatherForecasts getGetWeatherByZipCodeResult() { + return getWeatherByZipCodeResult; + } + + /** + * Sets the value of the getWeatherByZipCodeResult property. + * + * @param value + * allowed object is + * {@link WeatherForecasts } + * + */ + public void setGetWeatherByZipCodeResult(WeatherForecasts value) { + this.getWeatherByZipCodeResult = value; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/ObjectFactory.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/ObjectFactory.java new file mode 100644 index 0000000000..0c4fdbcde1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/ObjectFactory.java @@ -0,0 +1,118 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.example.weather; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.example.weather package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _WeatherForecasts_QNAME = new QName("http://www.webservicex.net", "WeatherForecasts"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.example.weather + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link WeatherData } + * + */ + public WeatherData createWeatherData() { + return new WeatherData(); + } + + /** + * Create an instance of {@link GetWeatherByPlaceName } + * + */ + public GetWeatherByPlaceName createGetWeatherByPlaceName() { + return new GetWeatherByPlaceName(); + } + + /** + * Create an instance of {@link GetWeatherByPlaceNameResponse } + * + */ + public GetWeatherByPlaceNameResponse createGetWeatherByPlaceNameResponse() { + return new GetWeatherByPlaceNameResponse(); + } + + /** + * Create an instance of {@link GetWeatherByZipCodeResponse } + * + */ + public GetWeatherByZipCodeResponse createGetWeatherByZipCodeResponse() { + return new GetWeatherByZipCodeResponse(); + } + + /** + * Create an instance of {@link GetWeatherByZipCode } + * + */ + public GetWeatherByZipCode createGetWeatherByZipCode() { + return new GetWeatherByZipCode(); + } + + /** + * Create an instance of {@link WeatherForecasts } + * + */ + public WeatherForecasts createWeatherForecasts() { + return new WeatherForecasts(); + } + + /** + * Create an instance of {@link ArrayOfWeatherData } + * + */ + public ArrayOfWeatherData createArrayOfWeatherData() { + return new ArrayOfWeatherData(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link WeatherForecasts }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.webservicex.net", name = "WeatherForecasts") + public JAXBElement createWeatherForecasts(WeatherForecasts value) { + return new JAXBElement(_WeatherForecasts_QNAME, WeatherForecasts.class, null, value); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherData.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherData.java new file mode 100644 index 0000000000..a4ca6190b5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherData.java @@ -0,0 +1,219 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.example.weather; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for WeatherData complex type. + * + *

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

+ * <complexType name="WeatherData">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Day" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="WeatherImage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="MaxTemperatureF" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="MinTemperatureF" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="MaxTemperatureC" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="MinTemperatureC" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "WeatherData", propOrder = { + "day", + "weatherImage", + "maxTemperatureF", + "minTemperatureF", + "maxTemperatureC", + "minTemperatureC" +}) +public class WeatherData { + + @XmlElement(name = "Day") + protected String day; + @XmlElement(name = "WeatherImage") + protected String weatherImage; + @XmlElement(name = "MaxTemperatureF") + protected String maxTemperatureF; + @XmlElement(name = "MinTemperatureF") + protected String minTemperatureF; + @XmlElement(name = "MaxTemperatureC") + protected String maxTemperatureC; + @XmlElement(name = "MinTemperatureC") + protected String minTemperatureC; + + /** + * Gets the value of the day property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDay() { + return day; + } + + /** + * Sets the value of the day property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDay(String value) { + this.day = value; + } + + /** + * Gets the value of the weatherImage property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getWeatherImage() { + return weatherImage; + } + + /** + * Sets the value of the weatherImage property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setWeatherImage(String value) { + this.weatherImage = value; + } + + /** + * Gets the value of the maxTemperatureF property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMaxTemperatureF() { + return maxTemperatureF; + } + + /** + * Sets the value of the maxTemperatureF property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMaxTemperatureF(String value) { + this.maxTemperatureF = value; + } + + /** + * Gets the value of the minTemperatureF property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMinTemperatureF() { + return minTemperatureF; + } + + /** + * Sets the value of the minTemperatureF property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMinTemperatureF(String value) { + this.minTemperatureF = value; + } + + /** + * Gets the value of the maxTemperatureC property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMaxTemperatureC() { + return maxTemperatureC; + } + + /** + * Sets the value of the maxTemperatureC property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMaxTemperatureC(String value) { + this.maxTemperatureC = value; + } + + /** + * Gets the value of the minTemperatureC property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMinTemperatureC() { + return minTemperatureC; + } + + /** + * Sets the value of the minTemperatureC property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMinTemperatureC(String value) { + this.minTemperatureC = value; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherForecast.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherForecast.java new file mode 100644 index 0000000000..0902ce67fe --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherForecast.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.example.weather; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.logging.Logger; + +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import javax.xml.ws.WebEndpoint; +import javax.xml.ws.WebServiceClient; +import javax.xml.ws.WebServiceFeature; + + +/** + * Get one week weather forecast for valid zip code or Place name in USA + * + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.1.3-b02- + * Generated source version: 2.1 + * + */ +@WebServiceClient(name = "WeatherForecast", targetNamespace = "http://www.webservicex.net", wsdlLocation = "file:/C:/Tuscany/java/sca/demos/us-location/src/main/resources/wsdl/WeatherForecast.wsdl") +public class WeatherForecast + extends Service +{ + + private final static URL WEATHERFORECAST_WSDL_LOCATION; + private final static Logger logger = Logger.getLogger(com.example.weather.WeatherForecast.class.getName()); + + static { + URL url = null; + try { + URL baseUrl; + baseUrl = com.example.weather.WeatherForecast.class.getResource("."); + url = new URL(baseUrl, "file:/C:/Tuscany/java/sca/demos/us-location/src/main/resources/wsdl/WeatherForecast.wsdl"); + } catch (MalformedURLException e) { + logger.warning("Failed to create URL for the wsdl Location: 'file:/C:/Tuscany/java/sca/demos/us-location/src/main/resources/wsdl/WeatherForecast.wsdl', retrying as a local file"); + logger.warning(e.getMessage()); + } + WEATHERFORECAST_WSDL_LOCATION = url; + } + + public WeatherForecast(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + + public WeatherForecast() { + super(WEATHERFORECAST_WSDL_LOCATION, new QName("http://www.webservicex.net", "WeatherForecast")); + } + + /** + * + * @return + * returns WeatherForecastSoap + */ + @WebEndpoint(name = "WeatherForecastSoap") + public WeatherForecastSoap getWeatherForecastSoap() { + return super.getPort(new QName("http://www.webservicex.net", "WeatherForecastSoap"), WeatherForecastSoap.class); + } + + /** + * + * @param features + * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. + * @return + * returns WeatherForecastSoap + */ + @WebEndpoint(name = "WeatherForecastSoap") + public WeatherForecastSoap getWeatherForecastSoap(WebServiceFeature... features) { + return super.getPort(new QName("http://www.webservicex.net", "WeatherForecastSoap"), WeatherForecastSoap.class, features); + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherForecastSoap.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherForecastSoap.java new file mode 100644 index 0000000000..aa000a44d2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherForecastSoap.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 com.example.weather; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.1.3-b02- + * Generated source version: 2.1 + * + */ +@WebService(name = "WeatherForecastSoap", targetNamespace = "http://www.webservicex.net") +@XmlSeeAlso({ + ObjectFactory.class +}) +public interface WeatherForecastSoap { + + + /** + * Get one week weather forecast for a valid Zip Code(USA) + * + * @param zipCode + * @return + * returns com.example.weather.WeatherForecasts + */ + @WebMethod(operationName = "GetWeatherByZipCode", action = "http://www.webservicex.net/GetWeatherByZipCode") + @WebResult(name = "GetWeatherByZipCodeResult", targetNamespace = "http://www.webservicex.net") + @RequestWrapper(localName = "GetWeatherByZipCode", targetNamespace = "http://www.webservicex.net", className = "com.example.weather.GetWeatherByZipCode") + @ResponseWrapper(localName = "GetWeatherByZipCodeResponse", targetNamespace = "http://www.webservicex.net", className = "com.example.weather.GetWeatherByZipCodeResponse") + public WeatherForecasts getWeatherByZipCode( + @WebParam(name = "ZipCode", targetNamespace = "http://www.webservicex.net") + String zipCode); + + /** + * Get one week weather forecast for a place name(USA) + * + * @param placeName + * @return + * returns com.example.weather.WeatherForecasts + */ + @WebMethod(operationName = "GetWeatherByPlaceName", action = "http://www.webservicex.net/GetWeatherByPlaceName") + @WebResult(name = "GetWeatherByPlaceNameResult", targetNamespace = "http://www.webservicex.net") + @RequestWrapper(localName = "GetWeatherByPlaceName", targetNamespace = "http://www.webservicex.net", className = "com.example.weather.GetWeatherByPlaceName") + @ResponseWrapper(localName = "GetWeatherByPlaceNameResponse", targetNamespace = "http://www.webservicex.net", className = "com.example.weather.GetWeatherByPlaceNameResponse") + public WeatherForecasts getWeatherByPlaceName( + @WebParam(name = "PlaceName", targetNamespace = "http://www.webservicex.net") + String placeName); + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherForecasts.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherForecasts.java new file mode 100644 index 0000000000..8ded0946d9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/WeatherForecasts.java @@ -0,0 +1,251 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.example.weather; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for WeatherForecasts complex type. + * + *

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

+ * <complexType name="WeatherForecasts">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Latitude" type="{http://www.w3.org/2001/XMLSchema}float"/>
+ *         <element name="Longitude" type="{http://www.w3.org/2001/XMLSchema}float"/>
+ *         <element name="AllocationFactor" type="{http://www.w3.org/2001/XMLSchema}float"/>
+ *         <element name="FipsCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="PlaceName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="StateCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="Status" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="Details" type="{http://www.webservicex.net}ArrayOfWeatherData" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "WeatherForecasts", propOrder = { + "latitude", + "longitude", + "allocationFactor", + "fipsCode", + "placeName", + "stateCode", + "status", + "details" +}) +public class WeatherForecasts { + + @XmlElement(name = "Latitude") + protected float latitude; + @XmlElement(name = "Longitude") + protected float longitude; + @XmlElement(name = "AllocationFactor") + protected float allocationFactor; + @XmlElement(name = "FipsCode") + protected String fipsCode; + @XmlElement(name = "PlaceName") + protected String placeName; + @XmlElement(name = "StateCode") + protected String stateCode; + @XmlElement(name = "Status") + protected String status; + @XmlElement(name = "Details") + protected ArrayOfWeatherData details; + + /** + * Gets the value of the latitude property. + * + */ + public float getLatitude() { + return latitude; + } + + /** + * Sets the value of the latitude property. + * + */ + public void setLatitude(float value) { + this.latitude = value; + } + + /** + * Gets the value of the longitude property. + * + */ + public float getLongitude() { + return longitude; + } + + /** + * Sets the value of the longitude property. + * + */ + public void setLongitude(float value) { + this.longitude = value; + } + + /** + * Gets the value of the allocationFactor property. + * + */ + public float getAllocationFactor() { + return allocationFactor; + } + + /** + * Sets the value of the allocationFactor property. + * + */ + public void setAllocationFactor(float value) { + this.allocationFactor = value; + } + + /** + * Gets the value of the fipsCode property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getFipsCode() { + return fipsCode; + } + + /** + * Sets the value of the fipsCode property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setFipsCode(String value) { + this.fipsCode = value; + } + + /** + * Gets the value of the placeName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPlaceName() { + return placeName; + } + + /** + * Sets the value of the placeName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPlaceName(String value) { + this.placeName = value; + } + + /** + * Gets the value of the stateCode property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getStateCode() { + return stateCode; + } + + /** + * Sets the value of the stateCode property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setStateCode(String value) { + this.stateCode = value; + } + + /** + * Gets the value of the status property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getStatus() { + return status; + } + + /** + * Sets the value of the status property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setStatus(String value) { + this.status = value; + } + + /** + * Gets the value of the details property. + * + * @return + * possible object is + * {@link ArrayOfWeatherData } + * + */ + public ArrayOfWeatherData getDetails() { + return details; + } + + /** + * Sets the value of the details property. + * + * @param value + * allowed object is + * {@link ArrayOfWeatherData } + * + */ + public void setDetails(ArrayOfWeatherData value) { + this.details = value; + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/package-info.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/package-info.java new file mode 100644 index 0000000000..6543ed7abf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/com/example/weather/package-info.java @@ -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. + */ +@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.webservicex.net", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package com.example.weather; diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/location/LocationClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/location/LocationClient.java new file mode 100644 index 0000000000..35c114093a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/location/LocationClient.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 location; + +import java.io.StringWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import com.example.uszip.GetInfoByZIPResponse; +import com.example.uszip.USZipSoap; + +/** + * This client program to invoke the Mortgage LoanApproval service + */ +public class LocationClient { + + public static void main(String[] args) throws Exception { + + SCADomain domain = SCADomain.newInstance("USLocation.composite"); + USZipSoap zipService = domain.getService(USZipSoap.class, "USLocationService"); + + GetInfoByZIPResponse.GetInfoByZIPResult result = zipService.getInfoByZIP("94555"); + + GetInfoByZIPResponse response = new GetInfoByZIPResponse(); + response.setGetInfoByZIPResult(result); + + JAXBContext context = JAXBContext.newInstance(GetInfoByZIPResponse.class); + StringWriter writer = new StringWriter(); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + marshaller.marshal(response, writer); + + String xml = writer.toString(); + System.out.println(xml); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/location/USLocationImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/location/USLocationImpl.java new file mode 100644 index 0000000000..cf27332e60 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/location/USLocationImpl.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 location; + +import org.osoa.sca.annotations.AllowsPassByReference; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import com.example.uszip.USZipSoap; +import com.example.uszip.GetInfoByAreaCodeResponse.GetInfoByAreaCodeResult; +import com.example.uszip.GetInfoByCityResponse.GetInfoByCityResult; +import com.example.uszip.GetInfoByStateResponse.GetInfoByStateResult; +import com.example.uszip.GetInfoByZIPResponse.GetInfoByZIPResult; + +/** + * @version $Rev$ $Date$ + */ +@Service(USZipSoap.class) +@AllowsPassByReference +public class USLocationImpl implements USZipSoap { + @Reference + protected USZipSoap usZipService; + + public GetInfoByAreaCodeResult getInfoByAreaCode(String usAreaCode) { + return usZipService.getInfoByAreaCode(usAreaCode); + } + + public GetInfoByCityResult getInfoByCity(String usCity) { + return usZipService.getInfoByCity(usCity); + } + + public GetInfoByStateResult getInfoByState(String usState) { + return usZipService.getInfoByState(usState); + } + + public GetInfoByZIPResult getInfoByZIP(String usZip) { + return usZipService.getInfoByZIP(usZip); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/weather/WeatherForecastClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/weather/WeatherForecastClient.java new file mode 100644 index 0000000000..c03cf2955f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/weather/WeatherForecastClient.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 weather; + +import java.io.StringWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import com.example.weather.GetWeatherByZipCodeResponse; +import com.example.weather.WeatherForecastSoap; +import com.example.weather.WeatherForecasts; + +/** + * This client program to invoke the Mortgage LoanApproval service + */ +public class WeatherForecastClient { + + public static void main(String[] args) throws Exception { + + SCADomain domain = SCADomain.newInstance("WeatherForecast.composite"); + WeatherForecastSoap weatherService = domain.getService(WeatherForecastSoap.class, "WeatherForecastService"); + + WeatherForecasts result = weatherService.getWeatherByZipCode("94555"); + + // Dump the result as XML + + // Wrap the result so that it can be marshaled + GetWeatherByZipCodeResponse response = new GetWeatherByZipCodeResponse(); + response.setGetWeatherByZipCodeResult(result); + + // Marshal the JAXB object into XML + JAXBContext context = JAXBContext.newInstance(GetWeatherByZipCodeResponse.class); + StringWriter writer = new StringWriter(); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + marshaller.marshal(response, writer); + + String xml = writer.toString(); + System.out.println(xml); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/weather/WeatherForecastImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/weather/WeatherForecastImpl.java new file mode 100644 index 0000000000..cf50a6cd9e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/weather/WeatherForecastImpl.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 weather; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import com.example.weather.WeatherForecastSoap; +import com.example.weather.WeatherForecasts; + +/** + * @version $Rev$ $Date$ + */ +@Service(WeatherForecastSoap.class) +public class WeatherForecastImpl implements WeatherForecastSoap{ + @Reference + protected WeatherForecastSoap weatherForecast; + + public WeatherForecasts getWeatherByPlaceName(String placeName) { + return weatherForecast.getWeatherByPlaceName(placeName); + } + + public WeatherForecasts getWeatherByZipCode(String zipCode) { + return weatherForecast.getWeatherByZipCode(zipCode); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/zipcode/ZipCodeClient.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/zipcode/ZipCodeClient.java new file mode 100644 index 0000000000..c470230b7a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/zipcode/ZipCodeClient.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 zipcode; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This client program to invoke the Mortgage LoanApproval service + */ +public class ZipCodeClient { + + public static void main(String[] args) throws Exception { + + SCADomain domain = SCADomain.newInstance("ZipCode.composite"); + ZipCodeService zipService = domain.getService(ZipCodeService.class, "ZipCodeService"); + + String result = zipService.lookup("94555"); + System.out.println(result); + } +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/zipcode/ZipCodeService.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/zipcode/ZipCodeService.java new file mode 100644 index 0000000000..ec0f05dd6c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/zipcode/ZipCodeService.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 zipcode; + +import org.osoa.sca.annotations.Remotable; + +/** + * @version $Rev$ $Date$ + */ +@Remotable +public interface ZipCodeService { + String lookup(String zipCode); +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/zipcode/ZipCodeServiceImpl.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/zipcode/ZipCodeServiceImpl.java new file mode 100644 index 0000000000..284e5a3aa3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/java/zipcode/ZipCodeServiceImpl.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package zipcode; + +import java.io.StringWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.osoa.sca.ServiceRuntimeException; +import org.osoa.sca.annotations.AllowsPassByReference; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import com.example.uszip.GetInfoByZIPResponse; +import com.example.uszip.USZipSoap; +import com.example.uszip.GetInfoByZIPResponse.GetInfoByZIPResult; +import com.example.weather.GetWeatherByZipCodeResponse; +import com.example.weather.WeatherForecastSoap; +import com.example.weather.WeatherForecasts; + +/** + * @version $Rev$ $Date$ + */ +@Service(ZipCodeService.class) +@AllowsPassByReference +public class ZipCodeServiceImpl implements ZipCodeService { + @Reference + protected USZipSoap usZipService; + + @Reference + protected WeatherForecastSoap weatherForecast; + + public String lookup(String zipCode) { + GetInfoByZIPResult result1 = usZipService.getInfoByZIP(zipCode); + + GetInfoByZIPResponse response1 = new GetInfoByZIPResponse(); + response1.setGetInfoByZIPResult(result1); + + String xml1 = toXML(response1); + + WeatherForecasts result2 = weatherForecast.getWeatherByZipCode(zipCode); + // Wrap the result so that it can be marshaled + GetWeatherByZipCodeResponse response2 = new GetWeatherByZipCodeResponse(); + response2.setGetWeatherByZipCodeResult(result2); + + String xml2 = toXML(response2); + // Marshal the JAXB object into XML + return xml1 + "\n" + xml2; + } + + private String toXML(Object jaxb) { + try { + JAXBContext context = JAXBContext.newInstance(jaxb.getClass()); + StringWriter writer = new StringWriter(); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + marshaller.marshal(jaxb, writer); + return writer.toString(); + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/resources/USLocation.composite b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/resources/USLocation.composite new file mode 100644 index 0000000000..a171fe62c9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/resources/USLocation.composite @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/resources/WeatherForecast.composite b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/resources/WeatherForecast.composite new file mode 100644 index 0000000000..0e1b118e44 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/resources/WeatherForecast.composite @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/resources/ZipCode.composite b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/resources/ZipCode.composite new file mode 100644 index 0000000000..28d674c29b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/main/resources/ZipCode.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/test/java/zipcode/ZipCodeClientTestCase.java b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/test/java/zipcode/ZipCodeClientTestCase.java new file mode 100644 index 0000000000..019fce26d6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-20080910/samples/zipcode-jaxws/src/test/java/zipcode/ZipCodeClientTestCase.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 zipcode; + +import location.LocationClient; +import weather.WeatherForecastClient; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests that the callback server is available + */ +public class ZipCodeClientTestCase { + + @Before + public void startServer() throws Exception { + } + + @Test + public void testClient() throws Exception { + /* + System.out.println("Running LocationClient..."); + LocationClient.main(null); + System.out.println("Running WeatherForecastClient..."); + WeatherForecastClient.main(null); + */ + System.out.println("Running ZipCodeClient..."); + ZipCodeClient.main(null); + } + + @After + public void stopServer() throws Exception { + } +} -- cgit v1.2.3