From 6d685c8e138af8d18bc71181ec630ccb9a17bdd9 Mon Sep 17 00:00:00 2001 From: nash Date: Wed, 6 Apr 2011 22:03:35 +0000 Subject: Tag for 1.6.2-RC1 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1089647 13f79535-47bb-0310-9956-ffa450edef68 --- sca-java-1.x/tags/1.6.2-RC1/samples/README | 333 +++++++++++ .../samples/binding-echo-extension/README | 74 +++ .../samples/binding-echo-extension/build.xml | 49 ++ .../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 | 52 ++ .../echo/provider/EchoBindingPoliciedInvoker.java | 70 +++ .../echo/provider/EchoBindingProviderFactory.java | 61 ++ .../provider/EchoReferenceBindingProvider.java | 69 +++ .../echo/provider/EchoServiceBindingProvider.java | 80 +++ .../policy/EchoBindingEncryptionPolicy.java | 44 ++ .../EchoBindingEncryptionPolicyProcessor.java | 36 ++ .../echo/provider/policy/EchoBindingPolicy.java | 43 ++ .../policy/EchoBindingPolicyProcessor.java | 78 +++ .../provider/policy/EncryptionPolicyHandler.java | 47 ++ .../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 | 82 +++ .../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 | 37 ++ .../src/test/java/echo/Echo.java | 29 + .../src/test/java/echo/EchoComponentImpl.java | 45 ++ .../src/test/java/echo/EchoReferenceTestCase.java | 49 ++ .../src/test/java/echo/EchoServiceTestCase.java | 49 ++ .../src/test/resources/EchoBinding.composite | 37 ++ .../src/test/resources/definitions.xml | 39 ++ .../tags/1.6.2-RC1/samples/binding-echo/README | 103 ++++ .../samples/binding-echo/binding-echo.png | Bin 0 -> 7846 bytes .../samples/binding-echo/binding-echo.svg | 174 ++++++ .../tags/1.6.2-RC1/samples/binding-echo/build.xml | 73 +++ .../tags/1.6.2-RC1/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 | 45 ++ .../src/main/resources/EchoBinding.composite | 37 ++ .../src/test/java/echo/EchoBindingTestCase.java | 56 ++ .../samples/binding-notification-broker/README | 128 ++++ .../binding-notification-broker.png | Bin 0 -> 36945 bytes .../samples/binding-notification-broker/build.xml | 73 +++ .../samples/binding-notification-broker/pom.xml | 98 +++ .../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 | 141 +++++ .../binding-notification-consumer.png | Bin 0 -> 27279 bytes .../binding-notification-consumer/build.xml | 73 +++ .../samples/binding-notification-consumer/pom.xml | 116 ++++ .../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 | 149 +++++ .../binding-notification-producer.png | Bin 0 -> 21631 bytes .../binding-notification-producer/build.xml | 73 +++ .../samples/binding-notification-producer/pom.xml | 127 ++++ .../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 +++ sca-java-1.x/tags/1.6.2-RC1/samples/build.xml | 97 +++ .../samples/calculator-corba-reference/README | 141 +++++ .../samples/calculator-corba-reference/build.xml | 70 +++ .../samples/calculator-corba-reference/pom.xml | 74 +++ .../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/CalculatorCORBAReference.composite | 42 ++ .../CalculatorCORBAReferenceTestCase.java | 82 +++ .../java/calculator/CalculatorCORBAServant.java | 44 ++ .../calculator/idl/CalculatorCORBAService.java | 32 + .../idl/CalculatorCORBAServiceOperations.java | 36 ++ .../idl/_CalculatorCORBAServiceImplBase.java | 120 ++++ .../src/test/resources/CalculatorCORBA.idl | 33 ++ .../samples/calculator-corba-service/README | 145 +++++ .../samples/calculator-corba-service/build.xml | 70 +++ .../samples/calculator-corba-service/pom.xml | 74 +++ .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 30 + .../java/calculator/CalculatorCORBAServer.java | 44 ++ .../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/CalculatorCORBAServer.composite | 53 ++ .../calculator/CalculatorCORBAServerTestCase.java | 64 ++ .../calculator/idl/CalculatorCORBAService.java | 32 + .../idl/CalculatorCORBAServiceHelper.java | 104 ++++ .../idl/CalculatorCORBAServiceHolder.java | 57 ++ .../idl/CalculatorCORBAServiceOperations.java | 36 ++ .../idl/_CalculatorCORBAServiceStub.java | 143 +++++ .../src/test/resources/CalculatorCORBA.idl | 33 ++ .../samples/calculator-distributed/README | 436 ++++++++++++++ .../samples/calculator-distributed/build.xml | 89 +++ .../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 | 23 + .../src/main/resources/nodeB/Calculator.composite | 29 + .../resources/nodeB/META-INF/sca-contribution.xml | 23 + .../src/main/resources/nodeC/Calculator.composite | 29 + .../resources/nodeC/META-INF/sca-contribution.xml | 23 + .../calculator/CalculatorDistributedTestCase.java | 92 +++ .../samples/calculator-distributed/workspace.xml | 25 + .../calculator-implementation-policies/README | 266 +++++++++ .../calculator-implementation-policies/build.xml | 70 +++ .../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-rmi-reference/README | 138 +++++ .../samples/calculator-rmi-reference/build.xml | 71 +++ .../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 | 70 +++ .../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 ++ .../1.6.2-RC1/samples/calculator-script/README | 105 ++++ .../1.6.2-RC1/samples/calculator-script/build.xml | 70 +++ .../calculator-script/calculator-script.png | Bin 0 -> 23064 bytes .../calculator-script/calculator-script.svg | 334 +++++++++++ .../1.6.2-RC1/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 ++ .../1.6.2-RC1/samples/calculator-webapp/README | 118 ++++ .../samples/calculator-webapp/calculator-web.png | Bin 0 -> 22916 bytes .../samples/calculator-webapp/calculator-web.svg | 358 +++++++++++ .../1.6.2-RC1/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 | 23 + .../src/main/webapp/WEB-INF/geronimo-web.xml | 32 + .../src/main/webapp/WEB-INF/web.xml | 41 ++ .../calculator-webapp/src/main/webapp/calc.jsp | 47 ++ .../1.6.2-RC1/samples/calculator-ws-webapp/README | 112 ++++ .../calculator-ws-webapp/calculator-web.png | Bin 0 -> 25757 bytes .../calculator-ws-webapp/calculator-web.svg | 455 ++++++++++++++ .../1.6.2-RC1/samples/calculator-ws-webapp/pom.xml | 103 ++++ .../src/main/java/calculator/AddService.java | 31 + .../src/main/java/calculator/AddServiceImpl.java | 34 ++ .../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 | 23 + .../src/main/webapp/WEB-INF/geronimo-web.xml | 40 ++ .../src/main/webapp/WEB-INF/web.xml | 41 ++ .../calculator-ws-webapp/src/main/webapp/calc.jsp | 50 ++ .../tags/1.6.2-RC1/samples/calculator/README | 97 +++ .../tags/1.6.2-RC1/samples/calculator/build.xml | 70 +++ .../1.6.2-RC1/samples/calculator/calculator.png | Bin 0 -> 20552 bytes .../1.6.2-RC1/samples/calculator/calculator.svg | 329 +++++++++++ .../tags/1.6.2-RC1/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 ++ .../1.6.2-RC1/samples/callback-ws-client/README | 311 ++++++++++ .../1.6.2-RC1/samples/callback-ws-client/build.xml | 71 +++ .../callback-ws-client/callback-ws-client.png | Bin 0 -> 8812 bytes .../callback-ws-client/callback-ws-client.svg | 204 +++++++ .../1.6.2-RC1/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 ++ .../1.6.2-RC1/samples/callback-ws-service/README | 227 +++++++ .../samples/callback-ws-service/build.xml | 71 +++ .../callback-ws-service/callback-ws-service.png | Bin 0 -> 8949 bytes .../callback-ws-service/callback-ws-service.svg | 200 +++++++ .../1.6.2-RC1/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 ++ .../tags/1.6.2-RC1/samples/callbacks-jms/README | 73 +++ .../tags/1.6.2-RC1/samples/callbacks-jms/build.xml | 70 +++ .../tags/1.6.2-RC1/samples/callbacks-jms/pom.xml | 103 ++++ .../src/main/java/callbacks/CallbackJMSClient.java | 44 ++ .../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 ++ .../tags/1.6.2-RC1/samples/chat-webapp/README | 92 +++ .../1.6.2-RC1/samples/chat-webapp/chat-webapp.png | Bin 0 -> 6552 bytes .../1.6.2-RC1/samples/chat-webapp/chat-webapp.svg | 187 ++++++ .../tags/1.6.2-RC1/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 | 23 + .../src/main/webapp/WEB-INF/geronimo-web.xml | 40 ++ .../chat-webapp/src/main/webapp/WEB-INF/web.xml | 37 ++ .../samples/chat-webapp/src/main/webapp/chat.html | 70 +++ .../tags/1.6.2-RC1/samples/databinding-echo/README | 143 +++++ .../1.6.2-RC1/samples/databinding-echo/build.xml | 73 +++ .../samples/databinding-echo/databinding-echo.png | Bin 0 -> 23907 bytes .../samples/databinding-echo/databinding-echo.svg | 408 +++++++++++++ .../1.6.2-RC1/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 ++ .../1.6.2-RC1/samples/domain-management/README | 201 +++++++ .../1.6.2-RC1/samples/domain-management/pom.xml | 263 ++++++++ .../java/manager/DistributeAndRunComponents.java | 329 +++++++++++ .../main/java/manager/DistributeComponents.java | 289 +++++++++ .../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 + .../samples/feed-aggregator-webapp/README | 61 ++ .../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 | 25 + .../src/main/webapp/WEB-INF/geronimo-web.xml | 40 ++ .../src/main/webapp/WEB-INF/web.xml | 41 ++ .../src/main/webapp/index.html | 33 ++ .../tags/1.6.2-RC1/samples/feed-aggregator/README | 110 ++++ .../1.6.2-RC1/samples/feed-aggregator/build.xml | 70 +++ .../samples/feed-aggregator/feed-aggregator.png | Bin 0 -> 17429 bytes .../samples/feed-aggregator/feed-aggregator.svg | 364 ++++++++++++ .../tags/1.6.2-RC1/samples/feed-aggregator/pom.xml | 84 +++ .../src/main/java/feed/AggregatorImpl.java | 199 +++++++ .../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 | 61 ++ .../src/test/java/feed/FeedAggregatorTestCase.java | 397 +++++++++++++ .../tags/1.6.2-RC1/samples/helloworld-bpel/README | 145 +++++ .../1.6.2-RC1/samples/helloworld-bpel/build.xml | 94 +++ .../samples/helloworld-bpel/helloworld-bpel.png | Bin 0 -> 8897 bytes .../samples/helloworld-bpel/helloworld-bpel.svg | 179 ++++++ .../tags/1.6.2-RC1/samples/helloworld-bpel/pom.xml | 209 +++++++ .../src/main/java/helloworld/BPELClient.java | 43 ++ .../src/main/resources/helloworld.bpel | 66 +++ .../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-dojo-webapp/README | 108 ++++ .../samples/helloworld-dojo-webapp/build-dojo.xml | 95 +++ .../samples/helloworld-dojo-webapp/build.xml | 67 +++ .../helloworld-dojo-webapp/helloworld-jsonrpc.png | Bin 0 -> 9947 bytes .../helloworld-dojo-webapp/helloworld-jsonrpc.svg | 177 ++++++ .../samples/helloworld-dojo-webapp/pom.xml | 156 +++++ .../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 | 25 + .../src/main/webapp/WEB-INF/geronimo-web.xml | 40 ++ .../src/main/webapp/WEB-INF/web.xml | 41 ++ .../src/main/webapp/style.css | 22 + .../samples/helloworld-erlang-reference/README | 127 ++++ .../helloworld-reference.png | Bin 0 -> 15780 bytes .../helloworld-reference.svg | 153 +++++ .../samples/helloworld-erlang-reference/pom.xml | 106 ++++ .../java/helloworld/HelloWorldErlangClient.java | 36 ++ .../src/main/java/helloworld/HelloWorldImpl.java | 33 ++ .../main/java/helloworld/HelloWorldService.java | 29 + .../helloworld/HelloWorldServiceComponent.java | 39 ++ .../resources/helloworlderlangreference.composite | 35 ++ .../resources/helloworlderlangservice.composite | 34 ++ .../src/main/resources/logging.properties | 30 + .../helloworld/HelloWorldErlangClientTestCase.java | 88 +++ .../helloworld/dynaignore/IgnorableRunner.java | 139 +++++ .../java/helloworld/dynaignore/IgnoreTest.java | 29 + .../samples/helloworld-erlang-service/README | 111 ++++ .../helloworld-service.png | Bin 0 -> 11273 bytes .../helloworld-service.svg | 148 +++++ .../samples/helloworld-erlang-service/pom.xml | 89 +++ .../src/main/java/helloworld/HelloWorldImpl.java | 33 ++ .../src/main/java/helloworld/HelloWorldServer.java | 84 +++ .../main/java/helloworld/HelloWorldService.java | 31 + .../resources/helloworlderlangservice.composite | 35 ++ .../helloworld/HelloWorldErlangServerTestCase.java | 87 +++ .../helloworld/dynaignore/IgnorableRunner.java | 139 +++++ .../java/helloworld/dynaignore/IgnoreTest.java | 29 + .../samples/helloworld-jsonrpc-webapp/README | 94 +++ .../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 | 25 + .../src/main/webapp/WEB-INF/geronimo-web.xml | 40 ++ .../src/main/webapp/WEB-INF/web.xml | 41 ++ .../src/main/webapp/style.css | 22 + .../samples/helloworld-reference-jms/README | 114 ++++ .../samples/helloworld-reference-jms/build.xml | 70 +++ .../helloworld-reference.png | Bin 0 -> 12973 bytes .../helloworld-reference.svg | 144 +++++ .../samples/helloworld-reference-jms/pom.xml | 103 ++++ .../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 | 70 +++ .../helloworld-service-jms/helloworld-service.png | Bin 0 -> 9455 bytes .../helloworld-service-jms/helloworld-service.svg | 139 +++++ .../samples/helloworld-service-jms/pom.xml | 96 +++ .../src/main/java/helloworld/HelloWorldImpl.java | 34 ++ .../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-ws-reference-jms/README | 127 ++++ .../samples/helloworld-ws-reference-jms/build.xml | 70 +++ .../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-secure/README | 176 ++++++ .../helloworld-ws-reference-secure/build.xml | 70 +++ .../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 -> 1354 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 | 70 +++ .../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 | 97 +++ .../samples/helloworld-ws-sdo-webapp/build.xml | 97 +++ .../helloworld-ws-sdo-webapp.png | Bin 0 -> 12242 bytes .../helloworld-ws-sdo-webapp.svg | 221 +++++++ .../samples/helloworld-ws-sdo-webapp/pom.xml | 211 +++++++ .../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 | 23 + .../src/main/webapp/WEB-INF/geronimo-web.xml | 48 ++ .../src/main/webapp/WEB-INF/web.xml | 46 ++ .../1.6.2-RC1/samples/helloworld-ws-sdo/README | 200 +++++++ .../1.6.2-RC1/samples/helloworld-ws-sdo/build.xml | 114 ++++ .../helloworld-ws-sdo/helloworld-ws-sdo.png | Bin 0 -> 7549 bytes .../helloworld-ws-sdo/helloworld-ws-sdo.svg | 150 +++++ .../1.6.2-RC1/samples/helloworld-ws-sdo/pom.xml | 165 ++++++ .../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 ++ .../main/java/services/bcircle/BioTestCase.java | 51 ++ .../java/services/bcircle/BiochemicalCircle.java | 29 + .../services/bcircle/BiochemicalCircleImpl.java | 40 ++ .../main/resources/META-INF/sca-contribution.xml | 23 + .../src/main/resources/helloworldws.composite | 32 + .../main/resources/helloworldwsclient.composite | 33 ++ .../src/main/resources/logging.properties | 30 + .../resources/clinicalLaboratory.composite | 34 ++ .../helloworld-ws-sdo/src/main/resources/test.xsd | 35 ++ .../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 | 70 +++ .../helloworld-ws-service.png | Bin 0 -> 6531 bytes .../helloworld-ws-service.svg | 150 +++++ .../samples/helloworld-ws-service-jms/pom.xml | 92 +++ .../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 | 36 ++ .../main/resources/helloworldwsjmspolicy.composite | 34 ++ .../src/main/resources/wsdl/helloworld.wsdl | 92 +++ .../HelloWorldJmsPolicyServerTestCase.java | 68 +++ .../helloworld/HelloWorldJmsServerTestCase.java | 84 +++ .../samples/helloworld-ws-service-secure/README | 152 +++++ .../samples/helloworld-ws-service-secure/build.xml | 70 +++ .../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 -> 1354 bytes .../src/main/resources/helloworldws.composite | 42 ++ .../src/main/resources/wsdl/helloworld.wsdl | 79 +++ .../java/helloworld/HelloWorldServerTestCase.java | 62 ++ .../1.6.2-RC1/samples/helloworld-ws-service/README | 141 +++++ .../samples/helloworld-ws-service/build.xml | 70 +++ .../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 ++ .../1.6.2-RC1/samples/holder-ws-service/README | 140 +++++ .../1.6.2-RC1/samples/holder-ws-service/build.xml | 70 +++ .../1.6.2-RC1/samples/holder-ws-service/pom.xml | 79 +++ .../org/example/orderservice/ObjectFactory.java | 74 +++ .../main/java/org/example/orderservice/Order.java | 147 +++++ .../org/example/orderservice/OrderService.java | 55 ++ .../org/example/orderservice/OrderServiceImpl.java | 65 ++ .../example/orderservice/OrderServiceServer.java | 99 ++++ .../example/orderservice/OrderService_Service.java | 84 +++ .../java/org/example/orderservice/ReviewOrder.java | 82 +++ .../example/orderservice/ReviewOrderResponse.java | 82 +++ .../main/java/org/example/orderservice/Status.java | 75 +++ .../org/example/orderservice/package-info.java | 21 + .../META-INF/sca-deployables/orderws.composite | 33 ++ .../src/main/resources/wsdl/orderservice.wsdl | 89 +++ .../example/orderservice/OrderServiceTestCase.java | 104 ++++ .../samples/implementation-composite/README | 116 ++++ .../samples/implementation-composite/build.xml | 70 +++ .../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 | 59 ++ .../src/main/java/composite/Target.java | 30 + .../src/main/java/composite/TargetImpl.java | 44 ++ .../src/main/resources/InnerComposite.composite | 41 ++ .../src/main/resources/InnerComposite2.composite | 33 ++ .../main/resources/META-INF/sca-contribution.xml | 24 + .../src/main/resources/OuterComposite.composite | 39 ++ .../src/test/java/composite/CompositeTestCase.java | 50 ++ .../samples/implementation-crud-extension/README | 83 +++ .../implementation-crud-extension/build.xml | 49 ++ .../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 + .../1.6.2-RC1/samples/implementation-crud/README | 113 ++++ .../samples/implementation-crud/build.xml | 73 +++ .../implementation-crud/implementation-crud.png | Bin 0 -> 4227 bytes .../implementation-crud/implementation-crud.svg | 135 +++++ .../1.6.2-RC1/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 | 97 +++ .../samples/implementation-notification/build.xml | 70 +++ .../implementation-notification.png | Bin 0 -> 21543 bytes .../samples/implementation-notification/pom.xml | 76 +++ .../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 | 104 ++++ .../implementation-pojo-extension/build.xml | 74 +++ .../samples/implementation-pojo-extension/pom.xml | 99 ++++ .../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 | 173 ++++++ .../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/assembly/test.xml | 34 ++ .../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 ++ .../test/java/helloworld/HelloWorldTestClient.java | 40 ++ .../helloworld/HelloWorldImpl2.componentType | 26 + .../test/resources/helloworld/helloworld.composite | 33 ++ .../tags/1.6.2-RC1/samples/osgi-supplychain/README | 161 +++++ .../samples/osgi-supplychain/build-bundles.xml | 32 + .../1.6.2-RC1/samples/osgi-supplychain/build.xml | 126 ++++ .../samples/osgi-supplychain/osgi-supplychain.png | Bin 0 -> 13558 bytes .../samples/osgi-supplychain/osgi-supplychain.svg | 272 +++++++++ .../1.6.2-RC1/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 ++ .../tags/1.6.2-RC1/samples/photo-gallery/README | 30 + .../tags/1.6.2-RC1/samples/photo-gallery/build.xml | 71 +++ .../samples/photo-gallery/photo-gallery.png | Bin 0 -> 13625 bytes .../samples/photo-gallery/photo-gallery.svg | 226 +++++++ .../tags/1.6.2-RC1/samples/photo-gallery/pom.xml | 127 ++++ .../src/main/java/launch/LaunchGallery.java | 34 ++ .../src/main/java/services/Album.java | 29 + .../src/main/java/services/AlbumImpl.java | 95 +++ .../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.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 | 139 +++++ sca-java-1.x/tags/1.6.2-RC1/samples/pom.xml | 110 ++++ .../tags/1.6.2-RC1/samples/quote-xquery/README | 358 +++++++++++ .../tags/1.6.2-RC1/samples/quote-xquery/build.xml | 124 ++++ .../tags/1.6.2-RC1/samples/quote-xquery/pom.xml | 195 ++++++ .../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 | 114 ++++ .../xquery/quote/XQueryQuoteClientTestCase.java | 192 ++++++ .../java/xquery/quote/XQueryQuoteTestServer.java | 50 ++ .../1.6.2-RC1/samples/simple-bigbank-spring/README | 180 ++++++ .../samples/simple-bigbank-spring/build.xml | 70 +++ .../samples/simple-bigbank-spring/pom.xml | 229 +++++++ .../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 | 147 +++++ .../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 | 60 ++ .../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 ++ .../tags/1.6.2-RC1/samples/simple-bigbank/README | 101 ++++ .../1.6.2-RC1/samples/simple-bigbank/build.xml | 70 +++ .../tags/1.6.2-RC1/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 ++ .../1.6.2-RC1/samples/simple-callback-ws/README | 144 +++++ .../1.6.2-RC1/samples/simple-callback-ws/build.xml | 70 +++ .../1.6.2-RC1/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 ++ .../tags/1.6.2-RC1/samples/simple-callback/README | 97 +++ .../1.6.2-RC1/samples/simple-callback/build.xml | 70 +++ .../tags/1.6.2-RC1/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/spring-bigbank-calculator/README | 2 + .../samples/spring-bigbank-calculator/build.xml | 70 +++ .../samples/spring-bigbank-calculator/pom.xml | 117 ++++ .../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 | 53 ++ .../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 + .../calculator/CalculatorServiceTestCase.java | 33 ++ .../samples/spring-bigbank-checkaccount/README | 2 + .../samples/spring-bigbank-checkaccount/build.xml | 71 +++ .../samples/spring-bigbank-checkaccount/pom.xml | 145 +++++ .../account/checking/CheckingAccountDetails.java | 50 ++ .../account/checking/CheckingAccountService.java | 37 ++ .../checking/CheckingAccountServiceImpl.java | 66 +++ .../checking/server/CheckingAccountServer.java | 70 +++ .../AccountsDataPasswordCallbackHandler.java | 54 ++ .../account/security/BigbankCheckingsAcl.java | 48 ++ ...ckingsDeptAuthImplementationPolicyProvider.java | 90 +++ .../account/security/CheckingsDeptAuthPolicy.java | 46 ++ .../CheckingsDeptAuthPolicyInterceptor.java | 73 +++ .../CheckingsDeptAuthPolicyProviderFactory.java | 75 +++ .../CheckingsDeptAuthorizationPolicyHandler.java | 67 +++ .../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 ++ .../checkaccount/CheckAccountServiceTestCase.java | 33 ++ .../samples/spring-bigbank-stockquote/README | 2 + .../samples/spring-bigbank-stockquote/build.xml | 70 +++ .../samples/spring-bigbank-stockquote/pom.xml | 117 ++++ .../java/bigbank/stockquote/StockQuoteImpl.java | 38 ++ .../java/bigbank/stockquote/StockQuoteService.java | 30 + .../server/SCAApplicationContextProvider.java | 37 ++ .../stockquote/server/StockQuoteServer.java | 58 ++ .../META-INF/spring/StockQuoteService-context.xml | 36 ++ .../src/main/resources/StockQuote.composite | 35 ++ .../stockquote/StockQuoteServiceTestCase.java | 33 ++ .../tags/1.6.2-RC1/samples/store-dojo/README | 38 ++ .../tags/1.6.2-RC1/samples/store-dojo/pom.xml | 144 +++++ .../store-dojo/src/main/java/launch/Launch.java | 34 ++ .../store-dojo/src/main/java/services/Cart.java | 28 + .../store-dojo/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 ++ .../store-dojo/src/main/java/services/Item.java | 51 ++ .../src/main/java/services/ShoppingCartImpl.java | 112 ++++ .../store-dojo/src/main/java/services/Total.java | 29 + .../store-dojo/src/main/resources/store.composite | 64 ++ .../src/main/resources/uiservices/store.html | 168 ++++++ .../tags/1.6.2-RC1/samples/store-dojo/store.png | Bin 0 -> 15670 bytes .../tags/1.6.2-RC1/samples/store-dojo/store.svg | 304 ++++++++++ .../tags/1.6.2-RC1/samples/store-secure/README | 40 ++ .../tags/1.6.2-RC1/samples/store-secure/build.xml | 70 +++ .../tags/1.6.2-RC1/samples/store-secure/pom.xml | 126 ++++ .../store-secure/src/main/java/launch/Launch.java | 34 ++ .../src/main/java/launch/LaunchProtected.java | 34 ++ .../src/main/java/launch/LaunchSSL.java | 34 ++ .../store-secure/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 ++ .../store-secure/src/main/java/services/Item.java | 51 ++ .../src/main/java/services/ShoppingCartImpl.java | 112 ++++ .../store-secure/src/main/java/services/Total.java | 29 + .../src/main/resources/definitions.xml | 50 ++ .../src/main/resources/store-protected.composite | 64 ++ .../src/main/resources/store-ssl.composite | 64 ++ .../src/main/resources/store.composite | 64 ++ .../src/main/resources/tuscany.keyStore | Bin 0 -> 1265 bytes .../src/main/resources/uiservices/store.html | 162 +++++ .../tags/1.6.2-RC1/samples/store-secure/store.png | Bin 0 -> 15670 bytes .../tags/1.6.2-RC1/samples/store-secure/store.svg | 304 ++++++++++ .../tags/1.6.2-RC1/samples/store-webapp/README | 41 ++ .../tags/1.6.2-RC1/samples/store-webapp/pom.xml | 122 ++++ .../store-webapp/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 ++ .../store-webapp/src/main/java/services/Item.java | 51 ++ .../src/main/java/services/ShoppingCartImpl.java | 112 ++++ .../store-webapp/src/main/java/services/Total.java | 29 + .../src/main/resources/store.composite | 61 ++ .../src/main/webapp/META-INF/sca-contribution.xml | 23 + .../src/main/webapp/WEB-INF/geronimo-web.xml | 50 ++ .../store-webapp/src/main/webapp/WEB-INF/web.xml | 36 ++ .../store-webapp/src/main/webapp/store.html | 162 +++++ .../tags/1.6.2-RC1/samples/store-webapp/store.png | Bin 0 -> 15670 bytes .../tags/1.6.2-RC1/samples/store-webapp/store.svg | 304 ++++++++++ sca-java-1.x/tags/1.6.2-RC1/samples/store/README | 38 ++ .../tags/1.6.2-RC1/samples/store/build.xml | 70 +++ sca-java-1.x/tags/1.6.2-RC1/samples/store/pom.xml | 121 ++++ .../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 +++++ .../tags/1.6.2-RC1/samples/store/store.png | Bin 0 -> 15670 bytes .../tags/1.6.2-RC1/samples/store/store.svg | 304 ++++++++++ .../tags/1.6.2-RC1/samples/supplychain/README | 101 ++++ .../tags/1.6.2-RC1/samples/supplychain/build.xml | 70 +++ .../tags/1.6.2-RC1/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 ++ .../1.6.2-RC1/samples/supplychain/supplychain.png | Bin 0 -> 3898 bytes .../1.6.2-RC1/samples/supplychain/supplychain.svg | 228 +++++++ .../tags/1.6.2-RC1/samples/web-resource/README | 76 +++ .../tags/1.6.2-RC1/samples/web-resource/build.xml | 70 +++ .../tags/1.6.2-RC1/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 ++++++ 1028 files changed, 64747 insertions(+) create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/EchoBinding.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/EchoBindingFactory.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingFactoryImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingProcessor.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingInvoker.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingPoliciedInvoker.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingProviderFactory.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoReferenceBindingProvider.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoServiceBindingProvider.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicy.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicyProcessor.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicy.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicyProcessor.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionPolicyHandler.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionStrategy.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/PolicyHandler.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/ReverseEncryptionStrategy.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicy.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicyProcessor.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/server/EchoServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/server/EchoServiceListener.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/resources/META-INF/services/echo.EchoBindingFactory create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/resources/sample-binding-echo.xsd create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/java/echo/Echo.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/java/echo/EchoComponentImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/java/echo/EchoReferenceTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/java/echo/EchoServiceTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/resources/EchoBinding.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/resources/definitions.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/binding-echo.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/binding-echo.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/main/java/echo/Echo.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/main/java/echo/EchoBindingClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/main/java/echo/EchoComponentImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/main/resources/EchoBinding.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/test/java/echo/EchoBindingTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/binding-notification-broker.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/java/notification/broker/TestCaseProducer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisory.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryConsumer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryProducer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.componentType create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/resources/wsdl/TrafficAdvisory.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/binding-notification-consumer.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisory.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryConsumer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.componentType create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/resources/wsdl/TrafficAdvisory.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/test/java/notification/consumer/TrafficAdvisoryTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/binding-notification-producer.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/java/notification/producer/TestCaseProducer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisory.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryProducer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.componentType create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/resources/wsdl/TrafficAdvisory.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/test/java/notification/producer/TrafficAdvisoryTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/resources/CalculatorCORBAReference.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/CalculatorCORBAReferenceTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/CalculatorCORBAServant.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/idl/CalculatorCORBAService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/idl/CalculatorCORBAServiceOperations.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/idl/_CalculatorCORBAServiceImplBase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/resources/CalculatorCORBA.idl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/CalculatorCORBAServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/resources/CalculatorCORBAServer.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/CalculatorCORBAServerTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAServiceHelper.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAServiceHolder.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAServiceOperations.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/_CalculatorCORBAServiceStub.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/resources/CalculatorCORBA.idl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/calculator-distributed.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/calculator-distributed.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/cloud.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/domain.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeB.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeC.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/node/LaunchDomain.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/cloud/NodeA.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/cloud/NodeB.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/cloud/NodeC.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/test/java/calculator/CalculatorDistributedTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/workspace.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/calculator.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/calculator.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/CalculatorCallbackHandler.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/JaasLoginModule.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/UserPrincipal.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/resources/CalculatorJass.config create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/resources/CalculatorLogMessages.properties create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/test/java/calculator/CalculatorTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/calculator-rmi-reference.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/calculator-rmi-reference.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/calculator-rmi-service.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/calculator-rmi-service.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/calculator-script.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/calculator-script.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/calculator/AddServiceImpl.js create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/calculator/DivideServiceImpl.groovy create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/calculator/MultiplyServiceImpl.py create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/calculator/SubtractServiceImpl.rb create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/test/java/calculator/CalculatorTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/calculator-web.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/calculator-web.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/webapp/calc.jsp create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/calculator-web.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/calculator-web.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/webapp/WEB-INF/geronimo-web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/webapp/calc.jsp create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/calculator.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/calculator.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/test/java/calculator/CalculatorTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/callback-ws-client.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/callback-ws-client.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/main/java/myapp/MyClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/main/java/myapp/MyClientImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/main/java/myserver/MyService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/main/java/myserver/MyServiceCallback.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/main/resources/myapp.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/test/java/myapp/CallbackClientTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/callback-ws-service.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/callback-ws-service.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/src/main/java/myserver/CallbackServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/src/main/java/myserver/MyService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/src/main/java/myserver/MyServiceCallback.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/src/main/java/myserver/MyServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/src/main/resources/callbackws.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/src/test/java/myserver/CallbackServerTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/CallbackJMSClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderCallback.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderRequest.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderResponse.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderServiceClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/resources/callbacks.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/resources/jndi.properties create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/test/java/callbacks/CallbacksTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/chat-webapp.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/chat-webapp.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/java/sample/ChatService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/java/sample/ChatServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/resources/chat.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/webapp/WEB-INF/geronimo-web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/webapp/chat.html create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/databinding-echo.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/databinding-echo.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/ComponentAImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/ComponentBImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/Echo.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/EchoDataBindingClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/Interface1.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/Interface2.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/resources/EchoDataBinding.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/resources/wsdl/echo.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/test/java/dbecho/EchoDataBindingTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/DistributeComponents.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/ListComponents.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/ListDependencies.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/ListDeployables.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/WireComponents.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/java/services/Cart.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/java/services/Item.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/java/services/ShoppingCartClientImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/java/services/ShoppingCartImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/assembly/assets.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/assembly/client.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/assembly/store.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/assets/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/client/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/client/client.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/store/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/store/store.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/feed-aggregator-webapp.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/feed-aggregator-webapp.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/java/feed/AggregatorImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/java/feed/Sort.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/java/feed/SortImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/resources/FeedAggregator.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/webapp/index.html create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/feed-aggregator.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/feed-aggregator.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/main/java/feed/Sort.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/main/java/feed/SortImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/main/java/launch/LaunchFeedServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/main/resources/FeedAggregator.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/helloworld-bpel.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/helloworld-bpel.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/resources/helloworld.bpel create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/resources/helloworld.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/resources/helloworld.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/resources/log4j.properties create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/build-dojo.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/helloworld-jsonrpc.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/helloworld-jsonrpc.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/java/helloworldjsonrpc/HelloWorldService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/resources/jsonrpc.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/HelloWorldJSONRPC.html create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/WEB-INF/geronimo-web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/style.css create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/helloworld-reference.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/helloworld-reference.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/java/helloworld/HelloWorldErlangClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/java/helloworld/HelloWorldServiceComponent.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/resources/helloworlderlangreference.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/resources/helloworlderlangservice.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/resources/logging.properties create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/test/java/helloworld/HelloWorldErlangClientTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/test/java/helloworld/dynaignore/IgnorableRunner.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/test/java/helloworld/dynaignore/IgnoreTest.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/helloworld-service.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/helloworld-service.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/main/java/helloworld/HelloWorldServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/main/resources/helloworlderlangservice.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/test/java/helloworld/HelloWorldErlangServerTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/test/java/helloworld/dynaignore/IgnorableRunner.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/test/java/helloworld/dynaignore/IgnoreTest.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/helloworld-jsonrpc.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/helloworld-jsonrpc.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/java/helloworldjsonrpc/HelloWorldService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/resources/jsonrpc.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/HelloWorldJSONRPC.html create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/WEB-INF/geronimo-web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/style.css create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/helloworld-reference.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/helloworld-reference.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldJmsClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldServiceComponent.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/resources/helloworldjmsreference.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/resources/helloworldjmsservice.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/resources/logging.properties create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/test/java/helloworld/HelloWorldJmsClientTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/helloworld-service.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/helloworld-service.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/resources/helloworldjmsservice.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/test/java/helloworld/HelloWorldJmsServerTestCaseOff.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/helloworld-ws-reference.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/helloworld-ws-reference.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldJmsClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldServiceComponent.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjms.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjmsclient.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/resources/logging.properties create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/test/java/helloworld/HelloWorldJmsClientTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/helloworld-ws-reference-secure.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/helloworld-ws-reference-secure.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/java/helloworld/ClientPWCBHandler.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldServiceComponent.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/helloworldKeys.jks create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/helloworldwsclient.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/logging.properties create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/test/java/helloworld/HelloWorldClientTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/test/java/helloworld/HelloWorldTestServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/helloworld-ws-reference.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/helloworld-ws-reference.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldServiceComponent.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/resources/logging.properties create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldClientTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldTestServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/helloworld-ws-sdo-webapp.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/helloworld-ws-sdo-webapp.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorld.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorldComponent.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/resources/helloworldws.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/resources/wsdl/helloworld.xsd create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/webapp/HelloWorld.jsp create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/webapp/WEB-INF/geronimo-web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/helloworld-ws-sdo.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/helloworld-ws-sdo.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServiceComponent.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BioTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircle.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircleImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/helloworldws.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/logging.properties create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/resources/clinicalLaboratory.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/test.xsd create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldClientTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldTestServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/helloworld-ws-service.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/helloworld-ws-service.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjms.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjmspolicy.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/test/java/helloworld/HelloWorldJmsPolicyServerTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/test/java/helloworld/HelloWorldJmsServerTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/helloworld-ws-service-secure.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/helloworld-ws-service-secure.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/java/helloworld/HelloWorldServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/java/helloworld/ServerPWCBHandler.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/resources/helloworldKeys.jks create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/resources/helloworldws.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/test/java/helloworld/HelloWorldServerTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/helloworld-ws-service.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/helloworld-ws-service.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/resources/META-INF/sca-deployables/helloworldws.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/src/test/java/helloworld/HelloWorldServerTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/ObjectFactory.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/Order.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderServiceServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderService_Service.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/ReviewOrder.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/ReviewOrderResponse.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/Status.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/package-info.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/resources/META-INF/sca-deployables/orderws.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/resources/wsdl/orderservice.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/test/java/org/example/orderservice/OrderServiceTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/implementation-composite.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/implementation-composite.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/CompositeClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/Source.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/SourceCallback.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/SourceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/Target.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/TargetImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/resources/InnerComposite.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/resources/InnerComposite2.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/resources/OuterComposite.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/test/java/composite/CompositeTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/CRUD.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementation.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementationFactory.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/backend/ResourceManager.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationFactoryImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationInvoker.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProvider.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProviderFactory.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/resources/META-INF/services/crud.CRUDImplementationFactory create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/resources/sample-implementation-crud.xsd create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/test/java/crud/CRUDTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/test/resources/crud.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/implementation-crud.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/implementation-crud.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/src/main/java/crud/client/CRUDClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/src/main/resources/crud.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/src/test/java/crud/client/CRUDTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/implementation-notification.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/java/notification/TestCaseProducer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/java/notification/TrafficAdvisory.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryConsumer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryProducer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.componentType create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/test/java/notification/TrafficAdvisoryTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/resources/sample-implementation-pojo.xsd create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/assembly/test.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/build-bundles.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/osgi-supplychain.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/osgi-supplychain.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/OSGiBundleImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/SupplyChainClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/customer/Customer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/retailer/Retailer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/shipper/JavaShipperComponentImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperComponentImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/shipper/Shipper.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/warehouse/JavaWarehouseComponentImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseComponentImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/warehouse/Warehouse.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/Customer.componentType create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSCustomer.componentType create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSRetailer.componentType create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSShipper.componentType create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSWarehouse.componentType create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/Retailer.componentType create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/Shipper.componentType create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/Warehouse.componentType create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/Customer.mf create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/Retailer.mf create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/Shipper.mf create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/Warehouse.mf create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.mf create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.mf create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.mf create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.mf create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/supplychain.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/supplychain.ds.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/photo-gallery.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/photo-gallery.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/java/launch/LaunchGallery.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/java/services/Album.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/java/services/AlbumImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery.html create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00368.jpg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00369.jpg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00370.jpg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00371.jpg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00373.jpg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00375.jpg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00376.jpg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00377.jpg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00378.jpg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00379.jpg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00380.jpg create mode 100755 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/index.gif create mode 100755 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/index_on.gif create mode 100755 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/next.gif create mode 100755 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/next_disabled.gif create mode 100755 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/next_on.gif create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/photo-gallery.composite create mode 100755 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/prev.gif create mode 100755 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/prev_disabled.gif create mode 100755 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/prev_on.gif create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/show_slide.gif create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/space.gif create mode 100755 sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/styles.css create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderNodeInfo.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/ExternalReferencesQuoteJoin.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProvider.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderNodeInfo.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/PropertiesQuoteJoin.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculator.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculatorImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteDataUtil.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoin.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocal.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocalImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_external_references.xq create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_properties.xq create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/AvailQuote.xsd create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/PriceQuote.xsd create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/Quote.xsd create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/xqueryquotews.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteClientTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteTestServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/simple-bigbank-spring.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/simple-bigbank-spring.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountReport.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountDetails.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/feed/AccountFeedImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountDetails.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountDetails.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/calculator/CalculatorService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/server/BigBankServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/stockquote/StockQuoteService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/BigBank.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/SavingsAccount.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/StockAccount.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/spring-context/Account-spring-context.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/spring-context/SavingsAccount-context.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/spring-context/StockAccount/META-INF/MANIFEST.MF create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/spring-context/StockAccount/META-INF/spring/StockAccount-context.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/web/style.css create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/test/java/bigbank/BigBankTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/simple-bigbank.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/simple-bigbank.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/account/AccountReport.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/account/AccountService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/account/AccountServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/Account.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/CheckingAccount.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/SavingsAccount.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/StockAccount.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/client/BigBankClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/resources/Account.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/resources/BigBank.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/resources/StockQuote.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/test/java/bigbank/BigBankTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/simple-callback-ws.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/simple-callback-ws.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/MyClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/MyClientImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/MyService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceCallback.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/SimpleCallbackClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/resources/simplecallback.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/test/java/simplecallback/SimpleCallbackTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/simple-callback.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/simple-callback.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/MyClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/MyClientImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/MyService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/MyServiceCallback.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/MyServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/SimpleCallbackClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/resources/simplecallback.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/test/java/simplecallback/SimpleCallbackTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/AddService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/CalculatorService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/DivideService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/MultiplyService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/SubtractService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/server/CalculatorServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/META-INF/spring/CalculatorService-context.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/calculator/AddServiceImpl.js create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/calculator/DivideServiceImpl.groovy create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/calculator/MultiplyServiceImpl.py create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/calculator/SubtractServiceImpl.rb create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/test/java/bigbank/calculator/CalculatorServiceTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountDetails.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/server/CheckingAccountServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/AccountsDataPasswordCallbackHandler.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/BigbankCheckingsAcl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthImplementationPolicyProvider.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicy.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyInterceptor.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyProviderFactory.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyHandler.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyProcessor.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/resources/CheckingsAccount.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/resources/spring-context/META-INF/spring/CheckingAccountService-context.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/test/java/bigbank/checkaccount/CheckAccountServiceTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/StockQuoteImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/StockQuoteService.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/SCAApplicationContextProvider.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/StockQuoteServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/resources/META-INF/spring/StockQuoteService-context.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/resources/StockQuote.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/test/java/bigbank/stockquote/StockQuoteServiceTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/launch/Launch.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/Cart.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/Catalog.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/CurrencyConverter.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/CurrencyConverterImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/FruitsCatalogImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/Item.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/ShoppingCartImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/Total.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/resources/store.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/resources/uiservices/store.html create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/store.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/store.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/launch/Launch.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/launch/LaunchProtected.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/launch/LaunchSSL.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/Cart.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/Catalog.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/CurrencyConverter.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/CurrencyConverterImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/FruitsCatalogImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/Item.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/ShoppingCartImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/Total.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/store-protected.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/store-ssl.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/store.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/tuscany.keyStore create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/uiservices/store.html create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/store.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/store.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/Cart.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/Catalog.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/CurrencyConverter.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/CurrencyConverterImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/FruitsCatalogImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/Item.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/ShoppingCartImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/Total.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/resources/store.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/WEB-INF/geronimo-web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/store.html create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/store.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/store.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/launch/Launch.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/Cart.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/Catalog.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/CurrencyConverter.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/CurrencyConverterImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/FruitsCatalogImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/Item.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/ShoppingCartImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/Total.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/resources/store.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/resources/uiservices/store.html create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/store.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/store/store.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/Customer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/CustomerComponentImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/Retailer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/RetailerComponentImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/Shipper.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/ShipperComponentImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/SupplyChainClient.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/Warehouse.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/WarehouseComponentImpl.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/resources/supplychain.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/supplychain.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/supplychain.svg create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/README create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/build.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/pom.xml create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/src/main/java/web/resource/SampleServer.java create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/src/main/resources/WebResource.composite create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/src/main/resources/myContent/index.html create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/web-resource.png create mode 100644 sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/web-resource.svg (limited to 'sca-java-1.x/tags/1.6.2-RC1/samples') diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/README b/sca-java-1.x/tags/1.6.2-RC1/samples/README new file mode 100644 index 0000000000..5bfe8de281 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/README @@ -0,0 +1,333 @@ +The Apache Tuscany SCA Samples +============================== +The Apache Tuscany SCA samples are built as part of the main Maven build and +run, using the provided JUnit test cases, as tests in the Maven build. + +In the binary distribution of Apache Tuscany the samples can also be built +and 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 notifications +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-corba-reference - The calculator configured to use existing + CORBA service +calculator-corba-service - The calculator configured to be accessible + as CORBA service +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 + +callbacks-jms - Shows how to use callbacks with JMS + +callback-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 + +domain-management - Shows how to use domain management APIs + +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-reference-jms - The client side of a hello world sample that uses a + JMS binding (requires helloworld-service-jms) +helloworld-service-jms - The server side of a hello world sample that uses a + JMS 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-jms) +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 + +holder-ws-service - Sample web service that uses a JAX-WS holder + +implementation-composite - Shows how SCA composites are used + +osgi-supplychain - SCA asynchronous API with OSGi and Java + implementation types + +photo-gallery - A sample SCA picture gallery application + +quote-xquery - Demonstrate SCA components using XQuery + +simple-bigbank - A banking application built with java components + and local wire + +simple-bigbank-spring - A banking application showing how SCA works with Spring +spring-bigbank-calculator - part of the simple-bigbank-spring sample +spring-bigbank-checkaccount - part of the simple-bigbank-spring sample +spring-bigbank-stockquote - part of the simple-bigbank-spring sample + +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 +store-secure - the Store application using security policies +store-webapp - the Store application running as a webapp + +supplychain - shows how asynchronous callbacks can be used + +web-resource - Demonstrates using an SCA Web resource component + +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-notification - 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 or higher +Apache Ant 1.7.1 or higher - if you are going to use Ant +Apache Maven 2.0.10 or higher - 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.1 + M2_HOME=//maven-2.0.10 + export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$M2_HOME/bin:$PATH + +For Windows: + set JAVA_HOME=C:\ + set ANT_HOME=C:\\apache-ant-1.7.1 + set M2_HOME=C:\\maven-2.0.10 + set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%M2_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 samples +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. + +If you are using the Apache Tuscany SCA source distribution, you can find +details of how to generate IDE project files (including IDE project files +for the samples) in the "Using an IDE" section of the BUILDING file. + +If you are using the Apache Tuscany SCA binary distribution, follow these +steps to generate IDE project files for all of the samples; + +cd samples + +If you are an Eclipse user do the following + +mvn eclipse:eclipse +mvn -Declipse.workspace= eclipse:add-maven-repo + +If you are an IDEA user do the following + +mvn idea:idea + +These commands generate project files for each module in the samples directory. +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 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/tags/1.6.2-RC1/samples/binding-echo-extension/README b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/README new file mode 100644 index 0000000000..94716b151f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/build.xml new file mode 100644 index 0000000000..e67700d2e0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/build.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/pom.xml new file mode 100644 index 0000000000..bf66970a4f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-binding-echo-extension + Apache Tuscany SCA Sample Echo Binding Extension + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-core-spi + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + test + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/EchoBinding.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/EchoBinding.java new file mode 100644 index 0000000000..20534fdba5 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/EchoBindingFactory.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/EchoBindingFactory.java new file mode 100644 index 0000000000..dc445b38b6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingFactoryImpl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingImpl.java new file mode 100644 index 0000000000..29e460e83a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingProcessor.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingProcessor.java new file mode 100644 index 0000000000..61ae9b9553 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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.IntentAttachPointType; +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.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 { + + 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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingInvoker.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingInvoker.java new file mode 100644 index 0000000000..1d9e28a899 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingInvoker.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.provider; + +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; + +import echo.server.EchoServer; + +/** + * Invoker for the sample echo binding. + */ +class EchoBindingInvoker implements Invoker { + private String uri; + + EchoBindingInvoker(String uri) { + this.uri = uri; + } + + 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 = EchoServer.getServer().call(uri, args); + + msg.setBody(result); + + } catch (Exception e) { + msg.setFaultBody(e); + } + return msg; + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingPoliciedInvoker.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingPoliciedInvoker.java new file mode 100644 index 0000000000..342fd6e0e7 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingPoliciedInvoker.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 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.EncryptionPolicyHandler; +import echo.provider.policy.PolicyHandler; + +/** + * 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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingProviderFactory.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingProviderFactory.java new file mode 100644 index 0000000000..adbc436950 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingProviderFactory.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 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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoReferenceBindingProvider.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoReferenceBindingProvider.java new file mode 100644 index 0000000000..3178c50a2a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoReferenceBindingProvider.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 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(binding.getURI()); + } + + public boolean supportsOneWayInvocation() { + return false; + } + + public InterfaceContract getBindingInterfaceContract() { + return reference.getInterfaceContract(); + } + + public void start() { + } + + public void stop() { + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoServiceBindingProvider.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoServiceBindingProvider.java new file mode 100644 index 0000000000..43eb562c55 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/EchoServiceBindingProvider.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 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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicy.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicy.java new file mode 100644 index 0000000000..c1f1269db6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicy.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.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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicyProcessor.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicyProcessor.java new file mode 100644 index 0000000000..da47bbfac3 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicyProcessor.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo.provider.policy; + +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicy.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicy.java new file mode 100644 index 0000000000..0dab68075d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicyProcessor.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionPolicyHandler.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionPolicyHandler.java new file mode 100644 index 0000000000..cf98b3830f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionPolicyHandler.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 echo.provider.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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionStrategy.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/PolicyHandler.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/ReverseEncryptionStrategy.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/ReverseEncryptionStrategy.java new file mode 100644 index 0000000000..3220102926 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicy.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicy.java new file mode 100644 index 0000000000..598683c251 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicyProcessor.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/server/EchoServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/server/EchoServer.java new file mode 100644 index 0000000000..7f3a4f9ac3 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/server/EchoServer.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 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 args + * @return + */ + public Object call(String uri, Object[] args) throws InvocationTargetException { + EchoServiceListener service = services.get(uri); + if (service == null) { + return args[0]; + } + return service.call(args); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/server/EchoServiceListener.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/java/echo/server/EchoServiceListener.java new file mode 100644 index 0000000000..bc6aa74037 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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 Object call(Object[] args) throws InvocationTargetException { + + // Create a request message + Message request = messageFactory.createMessage(); + request.setBody(args); + + // Dispatch and get the response + Message response = invoker.invoke(request); + Object body = response.getBody(); + if (response.isFault()) { + throw new InvocationTargetException((Throwable)body); + } + return body; + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/resources/META-INF/services/echo.EchoBindingFactory b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/resources/sample-binding-echo.xsd b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/resources/sample-binding-echo.xsd new file mode 100644 index 0000000000..75edf068ae --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/main/resources/sample-binding-echo.xsd @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/java/echo/Echo.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/java/echo/Echo.java new file mode 100644 index 0000000000..17981083ab --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/java/echo/EchoComponentImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/java/echo/EchoComponentImpl.java new file mode 100644 index 0000000000..cdfdfc3e8a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/java/echo/EchoComponentImpl.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 echo; + +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * A simple client component that uses a reference with an Echo binding. + * + * @version $Rev$ $Date$ + */ +@Service(Echo.class) +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/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/java/echo/EchoReferenceTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/java/echo/EchoReferenceTestCase.java new file mode 100644 index 0000000000..0775cfb84f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/java/echo/EchoReferenceTestCase.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 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("oof", result); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/java/echo/EchoServiceTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/java/echo/EchoServiceTestCase.java new file mode 100644 index 0000000000..3d8fbdc570 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/java/echo/EchoServiceTestCase.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 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 { + Object result = EchoServer.getServer().call("http://example.com/server", new Object[] {"foo"}); + assertEquals("oof", result); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/resources/EchoBinding.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/resources/EchoBinding.composite new file mode 100644 index 0000000000..3b81be5bf4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/resources/EchoBinding.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/resources/definitions.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo-extension/src/test/resources/definitions.xml new file mode 100644 index 0000000000..1cb1d1c9ba --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo/README b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/README new file mode 100644 index 0000000000..84367ab5f0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/README @@ -0,0 +1,103 @@ +Binding Echo Sample Application +=============================== +This sample demonstrates how to use the new binding extension +binding-echo-extension. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +If you just want to run it to see what happens, open a command prompt, +navigate to this sample directory, and do + +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\lib\tuscany-sca-manifest.jar;..\binding-echo-extension\target\sample-binding-echo-extension.jar;target\sample-binding-echo.jar echo.EchoBindingClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:../binding-echo-extension/target/sample-binding-echo-extension.jar:target/sample-binding-echo.jar echo.EchoBindingClient + +This looks like a long command. The three things we add to the classpath are + +tuscany-sca-manifest.jar - all of the standard Tuscany SCA runtime and + extension classes +sample-binding-echo-extension.jar - the new echo binding extension implementation +sample-binding-echo - the application that uses the echo binding + + +Sample Overview +--------------- +This sample contains an application (client and server code) that uses +an SCA binding that simply echoes back any messages that are sent to it. + +binding-echo/ + src/ + main/ + java/ + echo/ + Echo.java - interface definition for the sample + reference and service + EchoComponentImpl.java - sample component implementation with + echo binding reference + EchoBindingClient.java - sample client + resources/ + EchoBinding.composite - the SCA assembly for this sample + test/ + java/ + echo + EchoBindingTestCase.java - sample JUnit test case for the sample + client + binding-echo.png - pictorial representation of the sample + .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant as +follows. + +cd binding-echo +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] 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/tags/1.6.2-RC1/samples/binding-echo/binding-echo.png b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/binding-echo.png new file mode 100644 index 0000000000..a38d985363 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/binding-echo.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/binding-echo.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/binding-echo.svg new file mode 100644 index 0000000000..5b5051bef5 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/binding-echo.svg @@ -0,0 +1,174 @@ + + + + + + + + + + image/svg+xml + + + + + + + + EchoBinding + + + EchoComponent + + + + EchoSerivce EchoReference + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/build.xml new file mode 100644 index 0000000000..b09290837e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/pom.xml new file mode 100644 index 0000000000..ba63f07f2e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/pom.xml @@ -0,0 +1,71 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-binding-echo + Apache Tuscany SCA Sample Echo Binding Application + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + sample-binding-echo-extension + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/main/java/echo/Echo.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/main/java/echo/Echo.java new file mode 100644 index 0000000000..17981083ab --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-echo/src/main/java/echo/EchoBindingClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/main/java/echo/EchoBindingClient.java new file mode 100644 index 0000000000..046411a3a1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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 = (String)EchoServer.getServer().call("http://example.com/server", new Object[] {"bar"}); + System.out.println("Echo service = " + echoString); + + scaDomain.close(); + + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/main/java/echo/EchoComponentImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/main/java/echo/EchoComponentImpl.java new file mode 100644 index 0000000000..cdfdfc3e8a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/main/java/echo/EchoComponentImpl.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 echo; + +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * A simple client component that uses a reference with an Echo binding. + * + * @version $Rev$ $Date$ + */ +@Service(Echo.class) +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/tags/1.6.2-RC1/samples/binding-echo/src/main/resources/EchoBinding.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/main/resources/EchoBinding.composite new file mode 100644 index 0000000000..7b3de1a1f0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/main/resources/EchoBinding.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/test/java/echo/EchoBindingTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/test/java/echo/EchoBindingTestCase.java new file mode 100644 index 0000000000..85c892cd0a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-echo/src/test/java/echo/EchoBindingTestCase.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 echo; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +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 = (String)EchoServer.getServer().call("http://example.com/server", new Object[] {"bar"}); + assertEquals(echoString, "bar"); + } +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/README b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/README new file mode 100644 index 0000000000..d73d296bee --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/README @@ -0,0 +1,128 @@ +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. + +Sample Usage +------------ + +These instructions assume that you will start the notification samples in the +following order: + binding-notification-consumer + binding-notification-broker + binding-notification-producer + +For a clean shutdown without exceptions, you should end the notification samples +in the following order: + binding-notification-producer + binding-notification-broker + binding-notification-consumer + +This sample is run using the tuscany binary distribution. To see what it does, +first start the consumer sample. When this is running, open a command prompt, +navigate to this sample's directory and do + +ant run + +OR if you don't have ant, + +on Windows, use the following command: + +java -Dnotification.httpPort=8082 -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-binding-notification-broker.jar notification.broker.TrafficAdvisoryServer + +on *nix, use the following command: + +java -Dnotification.httpPort=8082 -cp ../../lib/tuscany-sca-manifest.jar:target/sample-binding-notification-broker.jar notification.broker.TrafficAdvisoryServer + +this should bring up the following prompt: + +Send a report value, ^C or 'end' 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=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-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 + binding-notification-broker.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 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:8082/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:8082/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 diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/binding-notification-broker.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-notification-broker/binding-notification-broker.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/build.xml new file mode 100644 index 0000000000..7c7be663a0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/pom.xml new file mode 100644 index 0000000000..0ba234d782 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/pom.xml @@ -0,0 +1,98 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-binding-notification-broker + Apache Tuscany SCA Sample Notification Binding Broker + 1.6.2 + A sample illustrating use of binding.notification + + + + org.apache.tuscany.sca + tuscany-implementation-notification + 1.6.2 + runtime + + + org.apache.tuscany.sca + tuscany-binding-notification + 1.6.2 + + + org.apache.tuscany.sca + tuscany-databinding + 1.6.2 + runtime + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-interface-wsdl + 1.6.2 + runtime + + + org.apache.tuscany.sca + tuscany-interface-wsdl-xml + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + install + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/java/notification/broker/TestCaseProducer.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisory.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryConsumer.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryProducer.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryServer.java new file mode 100644 index 0000000000..bed6630bdc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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 'end' 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/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.componentType b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.componentType new file mode 100644 index 0000000000..2dc70f8ed1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.componentType @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.composite new file mode 100644 index 0000000000..f490c34ea6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Consumer1 + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/resources/wsdl/TrafficAdvisory.wsdl b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/resources/wsdl/TrafficAdvisory.wsdl new file mode 100644 index 0000000000..b823bbebcc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-broker/src/main/resources/wsdl/TrafficAdvisory.wsdl @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/README b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/README new file mode 100644 index 0000000000..4993c5ce79 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/README @@ -0,0 +1,141 @@ +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. + +Sample Usage +------------ + +These instructions assume that you will start the notification samples in the +following order: + binding-notification-consumer + binding-notification-broker + binding-notification-producer + +For a clean shutdown without exceptions, you should end the notification samples +in the following order: + binding-notification-producer + binding-notification-broker + binding-notification-consumer + +This sample is run using the tuscany binary distribution. To see what it does, +open a command prompt, navigate to this sample's directory and do + +ant run + +OR if you don't have ant, + +on Windows, use the following command: + +java -Dnotification.httpPort=8083 -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-binding-notification-consumer.jar notification.consumer.TrafficAdvisoryServer + +on *nix, use the following command: + +java -Dnotification.httpPort=8083 -cp ../../lib/tuscany-sca-manifest.jar:target/sample-binding-notification-consumer.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=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-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 + test/ + java/ + notification.producer/ + TrafficAdvisoryTestCase.java - JUnit test case + resources/ + binding-notification-consumer.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 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 + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running notification.consumer.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. diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/binding-notification-consumer.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-notification-consumer/binding-notification-consumer.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/build.xml new file mode 100644 index 0000000000..06e12fdad6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/pom.xml new file mode 100644 index 0000000000..faf5ed54b2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/pom.xml @@ -0,0 +1,116 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-binding-notification-consumer + Apache Tuscany SCA Sample Notification Binding Consumer + 1.6.2 + A sample illustrating use of binding.notification + + + + org.apache.tuscany.sca + tuscany-implementation-notification + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-notification + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-interface-java-xml + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-interface-wsdl-xml + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + 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/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisory.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryConsumer.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryServer.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.componentType b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.componentType new file mode 100644 index 0000000000..2dc70f8ed1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.componentType @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.composite new file mode 100644 index 0000000000..8f9bcc4438 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.composite @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + Consumer1 + + + + + Consumer2 + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/resources/wsdl/TrafficAdvisory.wsdl b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/resources/wsdl/TrafficAdvisory.wsdl new file mode 100644 index 0000000000..b823bbebcc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/main/resources/wsdl/TrafficAdvisory.wsdl @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-consumer/src/test/java/notification/consumer/TrafficAdvisoryTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-notification-producer/README b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/README new file mode 100644 index 0000000000..b585c8c3e0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/README @@ -0,0 +1,149 @@ +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. + +Sample Usage +------------ + +These instructions assume that you will start the notification samples in the +following order: + binding-notification-consumer + binding-notification-broker + binding-notification-producer + +For a clean shutdown without exceptions, you should end the notification samples +in the following order: + binding-notification-producer + binding-notification-broker + binding-notification-consumer + +This sample is run using the tuscany binary distribution. To see what it does, +first start the consumer and broker samples. When these are running, open a +command prompt, navigate to this sample's directory and do + +ant run + +OR if you don't have ant, + +on Windows, use the following command: + +java -Dnotification.httpPort=8081 -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-binding-notification-producer.jar notification.producer.TrafficAdvisoryServer + +on *nix, use the following command: + +java -Dnotification.httpPort=8081 -cp ../../lib/tuscany-sca-manifest.jar:target/sample-binding-notification-producer.jar notification.producer.TrafficAdvisoryServer + +this should bring up the following prompt: + +Send a report value, ^C or 'end' 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=8081' 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-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 + binding-notification-producer.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 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:8081/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. diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/binding-notification-producer.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-notification-producer/binding-notification-producer.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/build.xml new file mode 100644 index 0000000000..9d3ec716cc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/pom.xml new file mode 100644 index 0000000000..4095b6ac71 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/pom.xml @@ -0,0 +1,127 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-binding-notification-producer + Apache Tuscany SCA Sample Notification Binding Producer + 1.6.2 + A sample illustrating use of binding.notification + + + + org.apache.tuscany.sca + tuscany-implementation-notification + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-notification + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-interface-wsdl-xml + 1.6.2 + runtime + + + + javax.servlet + servlet-api + 2.5 + provided + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + 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/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/java/notification/producer/TestCaseProducer.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisory.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryProducer.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryServer.java new file mode 100644 index 0000000000..876314aab6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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 'end' 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/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.componentType b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.componentType new file mode 100644 index 0000000000..2dc70f8ed1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.componentType @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.composite new file mode 100644 index 0000000000..2db6ea655b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/resources/wsdl/TrafficAdvisory.wsdl b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/resources/wsdl/TrafficAdvisory.wsdl new file mode 100644 index 0000000000..b823bbebcc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/main/resources/wsdl/TrafficAdvisory.wsdl @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/binding-notification-producer/src/test/java/notification/producer/TrafficAdvisoryTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/build.xml new file mode 100644 index 0000000000..dfb23f7d75 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/build.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/README b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/README new file mode 100644 index 0000000000..384c8774f4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/README @@ -0,0 +1,141 @@ +Calculator CORBA Reference Sample +================================= + +This sample illustrates the use of the Tuscany CORBA Binding to reference +services that are hosted as CORBA 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-corba-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-corba-service.jar calculator.CalculatorCORBAServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-calculator-corba-service.jar calculator.CalculatorCORBAServer + +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-corba-reference.jar calculator.CalculatorClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-calculator-corba-reference.jar calculator.CalculatorClient + +Sample Overview +--------------- +This sample extends the calculator sample by replacing the local wired +connections with CORBA bindings. Instead of local add, subtract, multiply and +divide components, a CORBA service implementation now provides the +add, subtract, multiply and divide interfaces and is hosted as an CORBA object. +References specified in the .composite file include a CORBA binding which targets +this CORBA object. The name service which is used in CORBA communication is +provided in the test case class - CalculatorCORBAReferenceTestCase.java. + +This sample adds a number of classes to the basic calculator sample: + +calculator-corba-reference/ + src/ + main/ + java/ + calculator/ + CalculatorService.java - as calculator sample + AddService.java - as calculator sample + SubtractService.java - as calculator sample + MultiplyService.java - as calculator sample + DivideService.java - as calculator sample + CalculatorClient.java - as calculator sample + CalculatorServiceImpl.java - calls the CORBA service + that provides the target for the + CORBA bindings in the composite + resources/ + CalculatorCORBAReference.composite - the SCA assembly for this sample + test/ + java/ + calculator/ + CalculatorCORBAReferenceTestCase.java - JUnit test case + CalculatorCORBAServant.java - CORBA service implementation + idl/ - contains files generated + from the IDL file. Files are + used to create a CORBA object which + will be consumed by SCA references. + _CalculatorCORBAServiceImplBase.java + CalculatorCORBAService.java + CalculatorCORBAServiceOperations.java + resources/ + CalculatorCORBA.idl - IDL description for CORBA object + 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 calculator-corba-service sample provides a CORBA server that acts as a target +for the SCA CORBA binding. Start a new console and use the following commands. + +cd calculator-corba-service +ant compile +ant run + +This will run up the server and display the following. + +run: + [java] Calculator CORBA server started (press enter to shutdown) + +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 CORBA binding +makes calls out to the CORBA server you started in the previous step. Start +a new console and use the following commands. + +cd calculator-corba-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-corba-reference +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running calculator.CalculatorCORBAReferenceTestCase +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/tags/1.6.2-RC1/samples/calculator-corba-reference/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/build.xml new file mode 100644 index 0000000000..e1633e0b7e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/pom.xml new file mode 100644 index 0000000000..190dfb9042 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/pom.xml @@ -0,0 +1,74 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-calculator-corba-reference + Apache Tuscany SCA Sample Calculator CORBA Reference + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + org.apache.tuscany.sca + tuscany-binding-corba-runtime + 1.6.2 + runtime + + + org.apache.tuscany.sca + tuscany-host-corba-jse + 1.6.2 + runtime + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/AddService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..ec57a6a533 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..168240fa01 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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("CalculatorCORBAReference.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/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..d310dad4b1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..f28f0ca179 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/DivideService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..835e4fda6d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/SubtractService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..30e4e6a56a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/resources/CalculatorCORBAReference.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/resources/CalculatorCORBAReference.composite new file mode 100644 index 0000000000..717add91a8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/main/resources/CalculatorCORBAReference.composite @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/CalculatorCORBAReferenceTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/CalculatorCORBAReferenceTestCase.java new file mode 100644 index 0000000000..041608273b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/CalculatorCORBAReferenceTestCase.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 calculator; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.corba.naming.TransientNameServer; +import org.apache.tuscany.sca.host.corba.naming.TransientNameService; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.omg.CORBA.ORB; +import org.omg.CosNaming.NameComponent; +import org.omg.CosNaming.NamingContext; +import org.omg.CosNaming.NamingContextHelper; + +/** + * This shows how to test the Calculator service component. + */ +public class CalculatorCORBAReferenceTestCase extends TestCase { + + private SCADomain scaDomain; + private CalculatorService calculatorService; + private TransientNameServer server; + + private void bindObject(String name, org.omg.CORBA.Object object) throws Exception { + ORB orb = server.getORB(); + org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); + NamingContext ncRef = NamingContextHelper.narrow(objRef); + NameComponent nc = new NameComponent(name, ""); + NameComponent path[] = {nc}; + ncRef.rebind(path, object); + } + + @BeforeClass + protected void setUp() throws Exception { + // create name service + server = new TransientNameServer("localhost", 5080, TransientNameService.DEFAULT_SERVICE_NAME); + Thread t = server.start(); + if (t == null) { + Assert.fail("The naming server cannot be started"); + } else { + // create CORBA object which will be accessible by SCA CORBA binding + bindObject("CalculatorCORBAService", new CalculatorCORBAServant()); + scaDomain = SCADomain.newInstance("CalculatorCORBAReference.composite"); + calculatorService = scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent"); + } + } + + @AfterClass + protected void tearDown() throws Exception { + scaDomain.close(); + server.stop(); + } + + @Test + public void testCalculator() throws Exception { + assertEquals(5.0, calculatorService.add(3, 2)); + assertEquals(1.0, calculatorService.subtract(3, 2)); + assertEquals(6.0, calculatorService.multiply(3, 2)); + assertEquals(1.5, calculatorService.divide(3, 2)); + } +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/CalculatorCORBAServant.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/CalculatorCORBAServant.java new file mode 100644 index 0000000000..65e9b89ce2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/CalculatorCORBAServant.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 calculator.idl._CalculatorCORBAServiceImplBase; + +public class CalculatorCORBAServant extends _CalculatorCORBAServiceImplBase { + + private static final long serialVersionUID = 1L; + + public double add(double arg1, double arg2) { + return arg1 + arg2; + } + + public double subtract(double arg1, double arg2) { + return arg1 - arg2; + } + + public double multiply(double arg1, double arg2) { + return arg1 * arg2; + } + + public double divide(double arg1, double arg2) { + return arg1 / arg2; + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/idl/CalculatorCORBAService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/idl/CalculatorCORBAService.java new file mode 100644 index 0000000000..83a1a5e23c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/idl/CalculatorCORBAService.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 calculator.idl; + + +/** +* calculator/idl/CalculatorCORBAService.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from CalculatorCORBA.idl +* roda, 15 padziernik 2008 16:02:31 CEST +*/ + +public interface CalculatorCORBAService extends CalculatorCORBAServiceOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity +{ +} // interface CalculatorCORBAService diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/idl/CalculatorCORBAServiceOperations.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/idl/CalculatorCORBAServiceOperations.java new file mode 100644 index 0000000000..ea9386dfef --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/idl/CalculatorCORBAServiceOperations.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.idl; + + +/** +* calculator/idl/CalculatorCORBAServiceOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from CalculatorCORBA.idl +* roda, 15 padziernik 2008 16:02:31 CEST +*/ + +public interface CalculatorCORBAServiceOperations +{ + double add (double arg1, double arg2); + double subtract (double arg1, double arg2); + double multiply (double arg1, double arg2); + double divide (double arg1, double arg2); +} // interface CalculatorCORBAServiceOperations diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/idl/_CalculatorCORBAServiceImplBase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/idl/_CalculatorCORBAServiceImplBase.java new file mode 100644 index 0000000000..c327e447e0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/java/calculator/idl/_CalculatorCORBAServiceImplBase.java @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator.idl; + + +/** +* calculator/idl/_CalculatorCORBAServiceImplBase.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from CalculatorCORBA.idl +* roda, 15 padziernik 2008 16:02:31 CEST +*/ + +public abstract class _CalculatorCORBAServiceImplBase extends org.omg.CORBA.portable.ObjectImpl + implements calculator.idl.CalculatorCORBAService, org.omg.CORBA.portable.InvokeHandler +{ + + // Constructors + public _CalculatorCORBAServiceImplBase () + { + } + + private static java.util.Hashtable _methods = new java.util.Hashtable (); + static + { + _methods.put ("add", new java.lang.Integer (0)); + _methods.put ("subtract", new java.lang.Integer (1)); + _methods.put ("multiply", new java.lang.Integer (2)); + _methods.put ("divide", new java.lang.Integer (3)); + } + + public org.omg.CORBA.portable.OutputStream _invoke (String $method, + org.omg.CORBA.portable.InputStream in, + org.omg.CORBA.portable.ResponseHandler $rh) + { + org.omg.CORBA.portable.OutputStream out = null; + java.lang.Integer __method = (java.lang.Integer)_methods.get ($method); + if (__method == null) + throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + + switch (__method.intValue ()) + { + case 0: // calculator/idl/CalculatorCORBAService/add + { + double arg1 = in.read_double (); + double arg2 = in.read_double (); + double $result = (double)0; + $result = this.add (arg1, arg2); + out = $rh.createReply(); + out.write_double ($result); + break; + } + + case 1: // calculator/idl/CalculatorCORBAService/subtract + { + double arg1 = in.read_double (); + double arg2 = in.read_double (); + double $result = (double)0; + $result = this.subtract (arg1, arg2); + out = $rh.createReply(); + out.write_double ($result); + break; + } + + case 2: // calculator/idl/CalculatorCORBAService/multiply + { + double arg1 = in.read_double (); + double arg2 = in.read_double (); + double $result = (double)0; + $result = this.multiply (arg1, arg2); + out = $rh.createReply(); + out.write_double ($result); + break; + } + + case 3: // calculator/idl/CalculatorCORBAService/divide + { + double arg1 = in.read_double (); + double arg2 = in.read_double (); + double $result = (double)0; + $result = this.divide (arg1, arg2); + out = $rh.createReply(); + out.write_double ($result); + break; + } + + default: + throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + } + + return out; + } // _invoke + + // Type-specific CORBA::Object operations + private static String[] __ids = { + "IDL:calculator/idl/CalculatorCORBAService:1.0"}; + + public String[] _ids () + { + return (String[])__ids.clone (); + } + + +} // class _CalculatorCORBAServiceImplBase diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/resources/CalculatorCORBA.idl b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/resources/CalculatorCORBA.idl new file mode 100644 index 0000000000..55ffeac8a3 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-reference/src/test/resources/CalculatorCORBA.idl @@ -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. + */ + +/* + * Compile by: idlj -fserver -oldImplBase CalculatorCORBA.idl + */ + +module calculator { + module idl { + interface CalculatorCORBAService { + double add(in double arg1, in double arg2); + double subtract(in double arg1, in double arg2); + double multiply(in double arg1, in double arg2); + double divide(in double arg1, in double arg2); + }; + }; +}; \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/README b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/README new file mode 100644 index 0000000000..965c1e7ad1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/README @@ -0,0 +1,145 @@ +Calculator CORBA Service Sample +=============================== + +This sample illustrates the use of the Tuscany CORBA Binding to expose +component services as CORBA objects. It also demonstrates how a simple +Java CORBA Client application invokes the SCA Application's services +exposed as CORBA objects. + +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-corba-service.jar calculator.CalculatorCORBAServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-calculator-corba-service.jar calculator.CalculatorCORBAServer + +Now you have the server running you need to open another command prompt, navigate +to the calculator-corba-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-corba-reference.jar calculator.CalculatorClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-calculator-corba-reference.jar calculator.CalculatorClient + +Sample Overview +--------------- +This sample extends the calculator sample by replacing the local service +binding with a CORBA binding. A Java client can use CORBA client code to +call the service exposed by the SCA application. The name service which is +used in CORBA communication is provided by the Tuscany CORBA hosting module +(maven dependency: tuscany-host-corba-jse-tns) - see the binding.corba reference +on the Apache Tuscany website for details. + +This sample adds a number of classes to the basic calculator sample: + +calculator-corba-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 + resources/ + CalculatorCORBAServer.composite - the SCA assembly for this sample + test/ + java/ + calculator/ + CalculatorCORBAServerTestCase.java - JUnit test case + idl/ - contains files generated + from the IDL file. Files are + used to access the SCA component. + CalculatorCORBAServiceHelper.java + CalculatorCORBAService.java + _CalculatorCORBAServiceStub.java + CalculatorCORBAServiceHolder.java + CalculatorCORBAServiceOperations.java + resources/ + CalculatorCORBA.idl - IDL description for SCA component + 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 a CORBA service. Start a new console and use the following +commands. + +cd calculator-corba-service +ant compile +ant run + +This will run up the server and display the following. + +run: + [java] Calculator CORBA server started (press enter to shutdown) + +The client is very similar to the calculator sample + +It locates the CORBA 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-corba-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-corba-service +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running calculator.CalculatorCORBAServerTestCase +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/tags/1.6.2-RC1/samples/calculator-corba-service/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/build.xml new file mode 100644 index 0000000000..c6216dcfc2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/pom.xml new file mode 100644 index 0000000000..408c38e293 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/pom.xml @@ -0,0 +1,74 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-calculator-corba-service + Apache Tuscany SCA Sample Calculator CORBA Service + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + org.apache.tuscany.sca + tuscany-binding-corba-runtime + 1.6.2 + runtime + + + org.apache.tuscany.sca + tuscany-host-corba-jse-tns + 1.6.2 + runtime + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/AddService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..ec57a6a533 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..e9c635e3c8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/CalculatorCORBAServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/CalculatorCORBAServer.java new file mode 100644 index 0000000000..aa6154e25a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/CalculatorCORBAServer.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 java.io.IOException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class CalculatorCORBAServer { + + public static void main(String[] args) { + SCADomain scaDomain; + try { + scaDomain = SCADomain.newInstance("CalculatorCORBAServer.composite"); + + System.out.println("Calculator CORBA server started (press enter to shutdown)"); + System.in.read(); + scaDomain.close(); + System.out.println("Calculator CORBA server stopped"); + } catch (IOException e) { + e.printStackTrace(); + } + + + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..3ddcef61df --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..f28f0ca179 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/DivideService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..835e4fda6d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..8c33862f6d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..c7fbc73c00 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/SubtractService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..30e4e6a56a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1a7f145ad8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-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/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/resources/CalculatorCORBAServer.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/resources/CalculatorCORBAServer.composite new file mode 100644 index 0000000000..1ab6cecef7 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/main/resources/CalculatorCORBAServer.composite @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/CalculatorCORBAServerTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/CalculatorCORBAServerTestCase.java new file mode 100644 index 0000000000..4248ca8573 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/CalculatorCORBAServerTestCase.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 calculator; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.omg.CORBA.ORB; + +import calculator.idl.CalculatorCORBAService; +import calculator.idl.CalculatorCORBAServiceHelper; + +/** + * This shows how to test the Calculator service component. + */ +public class CalculatorCORBAServerTestCase extends TestCase { + + private SCADomain scaDomain; + private CalculatorCORBAService calculatorService; + + @BeforeClass + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("CalculatorCORBAServer.composite"); + String[] args = {"-ORBInitialPort", "5080"}; + // retrieve CORBA object which is SCA component + ORB orb = ORB.init(args, null); + calculatorService = + CalculatorCORBAServiceHelper.narrow(orb + .string_to_object("corbaname::localhost:5080#CalculatorCORBAService")); + } + + @AfterClass + protected void tearDown() throws Exception { + scaDomain.close(); + } + + @Test + public void testCalculator() throws Exception { + assertEquals(5.0, calculatorService.add(3, 2)); + assertEquals(1.0, calculatorService.subtract(3, 2)); + assertEquals(6.0, calculatorService.multiply(3, 2)); + assertEquals(1.5, calculatorService.divide(3, 2)); + } +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAService.java new file mode 100644 index 0000000000..97deba8ad0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAService.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 calculator.idl; + + +/** +* calculator/idl/CalculatorCORBAService.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from CalculatorCORBA.idl +* roda, 15 padziernik 2008 15:59:26 CEST +*/ + +public interface CalculatorCORBAService extends CalculatorCORBAServiceOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity +{ +} // interface CalculatorCORBAService diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAServiceHelper.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAServiceHelper.java new file mode 100644 index 0000000000..3940e80c7b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAServiceHelper.java @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator.idl; + + +/** +* calculator/idl/CalculatorCORBAServiceHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from CalculatorCORBA.idl +* roda, 15 padziernik 2008 15:59:26 CEST +*/ + +abstract public class CalculatorCORBAServiceHelper +{ + private static String _id = "IDL:calculator/idl/CalculatorCORBAService:1.0"; + + public static void insert (org.omg.CORBA.Any a, calculator.idl.CalculatorCORBAService that) + { + org.omg.CORBA.portable.OutputStream out = a.create_output_stream (); + a.type (type ()); + write (out, that); + a.read_value (out.create_input_stream (), type ()); + } + + public static calculator.idl.CalculatorCORBAService extract (org.omg.CORBA.Any a) + { + return read (a.create_input_stream ()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + synchronized public static org.omg.CORBA.TypeCode type () + { + if (__typeCode == null) + { + __typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (calculator.idl.CalculatorCORBAServiceHelper.id (), "CalculatorCORBAService"); + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static calculator.idl.CalculatorCORBAService read (org.omg.CORBA.portable.InputStream istream) + { + return narrow (istream.read_Object (_CalculatorCORBAServiceStub.class)); + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, calculator.idl.CalculatorCORBAService value) + { + ostream.write_Object ((org.omg.CORBA.Object) value); + } + + public static calculator.idl.CalculatorCORBAService narrow (org.omg.CORBA.Object obj) + { + if (obj == null) + return null; + else if (obj instanceof calculator.idl.CalculatorCORBAService) + return (calculator.idl.CalculatorCORBAService)obj; + else if (!obj._is_a (id ())) + throw new org.omg.CORBA.BAD_PARAM (); + else + { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate (); + calculator.idl._CalculatorCORBAServiceStub stub = new calculator.idl._CalculatorCORBAServiceStub (); + stub._set_delegate(delegate); + return stub; + } + } + + public static calculator.idl.CalculatorCORBAService unchecked_narrow (org.omg.CORBA.Object obj) + { + if (obj == null) + return null; + else if (obj instanceof calculator.idl.CalculatorCORBAService) + return (calculator.idl.CalculatorCORBAService)obj; + else + { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate (); + calculator.idl._CalculatorCORBAServiceStub stub = new calculator.idl._CalculatorCORBAServiceStub (); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAServiceHolder.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAServiceHolder.java new file mode 100644 index 0000000000..ba67857ef2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAServiceHolder.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.idl; + +/** +* calculator/idl/CalculatorCORBAServiceHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from CalculatorCORBA.idl +* roda, 15 padziernik 2008 15:59:26 CEST +*/ + +public final class CalculatorCORBAServiceHolder implements org.omg.CORBA.portable.Streamable +{ + public calculator.idl.CalculatorCORBAService value = null; + + public CalculatorCORBAServiceHolder () + { + } + + public CalculatorCORBAServiceHolder (calculator.idl.CalculatorCORBAService initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = calculator.idl.CalculatorCORBAServiceHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + calculator.idl.CalculatorCORBAServiceHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return calculator.idl.CalculatorCORBAServiceHelper.type (); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAServiceOperations.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAServiceOperations.java new file mode 100644 index 0000000000..25e1f2bc1a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/CalculatorCORBAServiceOperations.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.idl; + + +/** +* calculator/idl/CalculatorCORBAServiceOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from CalculatorCORBA.idl +* roda, 15 padziernik 2008 15:59:26 CEST +*/ + +public interface CalculatorCORBAServiceOperations +{ + double add (double arg1, double arg2); + double subtract (double arg1, double arg2); + double multiply (double arg1, double arg2); + double divide (double arg1, double arg2); +} // interface CalculatorCORBAServiceOperations diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/_CalculatorCORBAServiceStub.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/_CalculatorCORBAServiceStub.java new file mode 100644 index 0000000000..c78a5ea161 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/java/calculator/idl/_CalculatorCORBAServiceStub.java @@ -0,0 +1,143 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator.idl; + + +/** +* calculator/idl/_CalculatorCORBAServiceStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from CalculatorCORBA.idl +* roda, 15 padziernik 2008 15:59:26 CEST +*/ + +public class _CalculatorCORBAServiceStub extends org.omg.CORBA.portable.ObjectImpl implements calculator.idl.CalculatorCORBAService +{ + + public double add (double arg1, double arg2) + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("add", true); + $out.write_double (arg1); + $out.write_double (arg2); + $in = _invoke ($out); + double $result = $in.read_double (); + return $result; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + return add (arg1, arg2 ); + } finally { + _releaseReply ($in); + } + } // add + + public double subtract (double arg1, double arg2) + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("subtract", true); + $out.write_double (arg1); + $out.write_double (arg2); + $in = _invoke ($out); + double $result = $in.read_double (); + return $result; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + return subtract (arg1, arg2 ); + } finally { + _releaseReply ($in); + } + } // subtract + + public double multiply (double arg1, double arg2) + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("multiply", true); + $out.write_double (arg1); + $out.write_double (arg2); + $in = _invoke ($out); + double $result = $in.read_double (); + return $result; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + return multiply (arg1, arg2 ); + } finally { + _releaseReply ($in); + } + } // multiply + + public double divide (double arg1, double arg2) + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("divide", true); + $out.write_double (arg1); + $out.write_double (arg2); + $in = _invoke ($out); + double $result = $in.read_double (); + return $result; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + return divide (arg1, arg2 ); + } finally { + _releaseReply ($in); + } + } // divide + + // Type-specific CORBA::Object operations + private static String[] __ids = { + "IDL:calculator/idl/CalculatorCORBAService:1.0"}; + + public String[] _ids () + { + return (String[])__ids.clone (); + } + + private void readObject (java.io.ObjectInputStream s) throws java.io.IOException + { + String str = s.readUTF (); + String[] args = null; + java.util.Properties props = null; + org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init (args, props).string_to_object (str); + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate (); + _set_delegate (delegate); + } + + private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException + { + String[] args = null; + java.util.Properties props = null; + String str = org.omg.CORBA.ORB.init (args, props).object_to_string (this); + s.writeUTF (str); + } +} // class _CalculatorCORBAServiceStub diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/resources/CalculatorCORBA.idl b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/resources/CalculatorCORBA.idl new file mode 100644 index 0000000000..5848bbaa2c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-corba-service/src/test/resources/CalculatorCORBA.idl @@ -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. + */ + +/* + * Compile by: idlj -fclient -oldImplBase CalculatorCORBA.idl + */ + +module calculator { + module idl { + interface CalculatorCORBAService { + double add(in double arg1, in double arg2); + double subtract(in double arg1, in double arg2); + double multiply(in double arg1, in double arg2); + double divide(in double arg1, in double arg2); + }; + }; +}; \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/README b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/README new file mode 100644 index 0000000000..3113202d90 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/README @@ -0,0 +1,436 @@ +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 typing 'q'. + + +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/tags/1.6.2-RC1/samples/calculator-distributed/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/build.xml new file mode 100644 index 0000000000..800cea1c94 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/build.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/calculator-distributed.png b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/calculator-distributed.png new file mode 100644 index 0000000000..7c0e175664 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/calculator-distributed.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/calculator-distributed.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/calculator-distributed.svg new file mode 100644 index 0000000000..be5a4b8185 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/cloud.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/cloud.composite new file mode 100644 index 0000000000..85e2f9c7f3 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/cloud.composite @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/domain.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/domain.composite new file mode 100644 index 0000000000..643e22d0cf --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/domain.composite @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/pom.xml new file mode 100644 index 0000000000..f7dbc07173 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/pom.xml @@ -0,0 +1,119 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-calculator-distributed + Apache Tuscany SCA Sample Distributed Calculator + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-node-launcher + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-domain-manager + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-node-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-sca + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-sca-axis2 + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-resource-runtime + 1.6.2 + runtime + + + + org.codehaus.woodstox + wstx-asl + 3.2.4 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.2 + test + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/AddService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..d7dc4473ad --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..e9b7e254e5 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..031fa8b912 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..da869e00fd --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/DivideService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..f7ac0b7287 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..b7dca792b2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/SubtractService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..78ab9c6ee0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1010207154 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java new file mode 100644 index 0000000000..3ff6c8969a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeB.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeB.java new file mode 100644 index 0000000000..50600eaedc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeC.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeC.java new file mode 100644 index 0000000000..95d8934665 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/node/LaunchDomain.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/java/node/LaunchDomain.java new file mode 100644 index 0000000000..8b4fe566a1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/cloud/NodeA.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/cloud/NodeA.composite new file mode 100644 index 0000000000..ed7fe55abc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/cloud/NodeA.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/cloud/NodeB.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/cloud/NodeB.composite new file mode 100644 index 0000000000..8f29cc17aa --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/cloud/NodeB.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/cloud/NodeC.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/cloud/NodeC.composite new file mode 100644 index 0000000000..9ad132b0d4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/cloud/NodeC.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite new file mode 100644 index 0000000000..172676a3c7 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..6bd74b32d1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite new file mode 100644 index 0000000000..b770dbe8d4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..d42788aae4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite new file mode 100644 index 0000000000..66caf0d17b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..c6983b0f9f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/test/java/calculator/CalculatorDistributedTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/src/test/java/calculator/CalculatorDistributedTestCase.java new file mode 100644 index 0000000000..2a6f3af002 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-distributed/workspace.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/workspace.xml new file mode 100644 index 0000000000..7d6d3dbdbd --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-distributed/workspace.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/README b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/README new file mode 100644 index 0000000000..bd66eee1c9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/build.xml new file mode 100644 index 0000000000..2bc335fae2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/calculator.png b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/calculator.png new file mode 100644 index 0000000000..995a57b1fd Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/calculator.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/calculator.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/calculator.svg new file mode 100644 index 0000000000..af34f07e04 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/pom.xml new file mode 100644 index 0000000000..0474cdc4da --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-calculator-impl-policies + Apache Tuscany SCA Sample Calculator using Implementation Policies + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + org.apache.tuscany.sca + tuscany-policy-logging + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-policy-security + 1.6.2 + runtime + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/AddService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..5a1e7a638a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..caf4d358df --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..2bce187049 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..ad87375529 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..ae4ed12b7b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/DivideService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..ef6a8b375b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..cd91935f08 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..c85357fcd8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/SubtractService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..56ee372fc4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1b669084d9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/CalculatorCallbackHandler.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/JaasLoginModule.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/UserPrincipal.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/resources/Calculator.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..d91bf88d96 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/resources/Calculator.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/resources/CalculatorJass.config b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/resources/CalculatorJass.config new file mode 100644 index 0000000000..0e7cb86633 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/resources/CalculatorLogMessages.properties b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/resources/CalculatorLogMessages.properties new file mode 100644 index 0000000000..f62125eaa9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/resources/definitions.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/main/resources/definitions.xml new file mode 100644 index 0000000000..6cccde0d13 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/test/java/calculator/CalculatorTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-implementation-policies/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..157570c3df --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-reference/README b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/README new file mode 100644 index 0000000000..837b5ce75f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-reference/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/build.xml new file mode 100644 index 0000000000..8c4ada4704 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/build.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/calculator-rmi-reference.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-reference/calculator-rmi-reference.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/calculator-rmi-reference.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/calculator-rmi-reference.svg new file mode 100644 index 0000000000..ba802e6717 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-reference/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/pom.xml new file mode 100644 index 0000000000..222da75bc2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/pom.xml @@ -0,0 +1,68 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-calculator-rmi-reference + Apache Tuscany SCA Sample Calculator RMI Reference + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + org.apache.tuscany.sca + tuscany-binding-rmi-runtime + 1.6.2 + runtime + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..ec57a6a533 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..cd1076c3f1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..d310dad4b1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..f28f0ca179 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..835e4fda6d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..30e4e6a56a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite new file mode 100644 index 0000000000..a5a6e1cd29 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java new file mode 100644 index 0000000000..15e00f5946 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java new file mode 100644 index 0000000000..d8ded42cb2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/README b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/README new file mode 100644 index 0000000000..454cdc0d37 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/build.xml new file mode 100644 index 0000000000..6de535e1fc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/calculator-rmi-service.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/calculator-rmi-service.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/calculator-rmi-service.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/calculator-rmi-service.svg new file mode 100644 index 0000000000..9253110f98 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/pom.xml new file mode 100644 index 0000000000..54cc69ef4d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/pom.xml @@ -0,0 +1,68 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-calculator-rmi-service + Apache Tuscany SCA Sample Calculator RMI Service + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + org.apache.tuscany.sca + tuscany-binding-rmi-runtime + 1.6.2 + runtime + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/AddService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..ec57a6a533 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..e9c635e3c8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..2b99485b68 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java new file mode 100644 index 0000000000..b698163c1b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..3ddcef61df --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..f28f0ca179 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..835e4fda6d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..8c33862f6d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..c7fbc73c00 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..30e4e6a56a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1a7f145ad8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite new file mode 100644 index 0000000000..34d90ab451 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java new file mode 100644 index 0000000000..8943dd24f6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-script/README b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/README new file mode 100644 index 0000000000..ab1dda13df --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-script/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/build.xml new file mode 100644 index 0000000000..b58578014c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/calculator-script.png b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/calculator-script.png new file mode 100644 index 0000000000..d3f8c491c3 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/calculator-script.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/calculator-script.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/calculator-script.svg new file mode 100644 index 0000000000..16939f9310 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-script/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/pom.xml new file mode 100644 index 0000000000..27b517ea9d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-calculator-script + Apache Tuscany SCA Sample Calculator using Scripting Languages + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-script + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-interface-wsdl-xml + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/AddService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..a235e648c7 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..243d1562dc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..c89043276e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..ba897fa301 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/DivideService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..497dafd4fd --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/SubtractService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..376b3e5bb9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/Calculator.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..8a765e6153 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/Calculator.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/calculator/AddServiceImpl.js b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/calculator/AddServiceImpl.js new file mode 100644 index 0000000000..1d4d221364 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/calculator/DivideServiceImpl.groovy b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/calculator/DivideServiceImpl.groovy new file mode 100644 index 0000000000..c31c1e8fd6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/calculator/MultiplyServiceImpl.py b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/calculator/MultiplyServiceImpl.py new file mode 100644 index 0000000000..d6f27ca7f5 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/calculator/SubtractServiceImpl.rb b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/main/resources/calculator/SubtractServiceImpl.rb new file mode 100644 index 0000000000..132a1d13b0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-script/src/test/java/calculator/CalculatorTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-script/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..fea8f62110 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-webapp/README b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/README new file mode 100644 index 0000000000..c88b92b206 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-webapp/calculator-web.png b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/calculator-web.png new file mode 100644 index 0000000000..896ddc4093 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/calculator-web.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/calculator-web.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/calculator-web.svg new file mode 100644 index 0000000000..00ed27556f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-webapp/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/pom.xml new file mode 100644 index 0000000000..7c547de126 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/pom.xml @@ -0,0 +1,95 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-calculator-webapp + war + Apache Tuscany SCA Sample Calculator in a WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.6.2 + + + + generate + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/AddService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..ec57a6a533 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..e9c635e3c8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..4787b728f4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..ad87375529 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..bf3b0303ec --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/DivideService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..835e4fda6d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..8c33862f6d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..c7fbc73c00 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/SubtractService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..30e4e6a56a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1a7f145ad8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-webapp/src/main/resources/Calculator.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..50c23af0b2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/resources/Calculator.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..8b60ae590c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..eb923ff313 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,32 @@ + + + + + + + org.apache.tuscany.sca + sample-calculator-webapp + 1.6.2 + war + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..b5a828d55b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-webapp/src/main/webapp/calc.jsp b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-webapp/src/main/webapp/calc.jsp new file mode 100644 index 0000000000..4bc5c984dd --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-ws-webapp/README b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/README new file mode 100644 index 0000000000..36c57521f4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/README @@ -0,0 +1,112 @@ +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 your web application server. + +To save space, the WAR file isn't included in the binary distribution. You can +build it by following the instructions below in "Building And Running The Sample +Using Ant" or "Building And Running The Sample Using Maven". + +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/tags/1.6.2-RC1/samples/calculator-ws-webapp/calculator-web.png b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/calculator-web.png new file mode 100644 index 0000000000..f482b8d1c8 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/calculator-web.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/calculator-web.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/calculator-web.svg new file mode 100644 index 0000000000..1b7015b156 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-ws-webapp/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/pom.xml new file mode 100644 index 0000000000..34a2a366e5 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/pom.xml @@ -0,0 +1,103 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-calculator-ws-webapp + war + Apache Tuscany SCA Sample Calculator Web Service in a WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.6.2 + + + + generate + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/AddService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..c3c789e745 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..a7049729f7 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..ad87375529 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..bf3b0303ec --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/DivideService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..835e4fda6d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..8c33862f6d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..c7fbc73c00 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/SubtractService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..30e4e6a56a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1a7f145ad8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/resources/Calculator.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..6415d5a896 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/resources/Calculator.composite @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..8b60ae590c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..d75918ddd9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,40 @@ + + + + + + + org.apache.tuscany.sca + sample-calculator-ws-webapp + 1.6.2 + war + + + + + org.apache.axiom + org.apache.axis2 + org.apache.commons + org.jdom + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/webapp/calc.jsp b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator-ws-webapp/src/main/webapp/calc.jsp new file mode 100644 index 0000000000..4c4366747d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator/README b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/README new file mode 100644 index 0000000000..ceb532faed --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/build.xml new file mode 100644 index 0000000000..a45cf9589e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/calculator.png b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/calculator.png new file mode 100644 index 0000000000..995a57b1fd Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/calculator.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/calculator.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/calculator.svg new file mode 100644 index 0000000000..0615925c50 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/pom.xml new file mode 100644 index 0000000000..a0a29fe21b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/pom.xml @@ -0,0 +1,71 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-calculator + Apache Tuscany SCA Sample Calculator + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/AddService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..188451ebac --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..7ca8fb04b5 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..3b2966e96d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..031fa8b912 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..3d861f2018 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/DivideService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..1323edf55a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..91b803bc9e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/SubtractService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..bf0d1882b6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..58cc4a3547 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/calculator/src/main/resources/Calculator.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..90872041b0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/main/resources/Calculator.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/test/java/calculator/CalculatorTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/calculator/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..1b7476534a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-client/README b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/README new file mode 100644 index 0000000000..66121362c9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-client/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/build.xml new file mode 100644 index 0000000000..0fada69531 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/build.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/callback-ws-client.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-client/callback-ws-client.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/callback-ws-client.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/callback-ws-client.svg new file mode 100644 index 0000000000..f49aeadbbf --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-client/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/pom.xml new file mode 100644 index 0000000000..72444cfc58 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/pom.xml @@ -0,0 +1,86 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-callback-ws-client + Apache Tuscany SCA Sample Callback Web Service Remote Client + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + org.apache.tuscany.sca + sample-callback-ws-service + 1.6.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/main/java/myapp/MyClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/main/java/myapp/MyClient.java new file mode 100644 index 0000000000..e515b55788 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-client/src/main/java/myapp/MyClientImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/main/java/myapp/MyClientImpl.java new file mode 100644 index 0000000000..ece769236c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-client/src/main/java/myserver/MyService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/main/java/myserver/MyService.java new file mode 100644 index 0000000000..1850eae1bc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-client/src/main/java/myserver/MyServiceCallback.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/main/java/myserver/MyServiceCallback.java new file mode 100644 index 0000000000..bf5f87a4f9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-client/src/main/resources/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-client/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/main/resources/myapp.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/main/resources/myapp.composite new file mode 100644 index 0000000000..5b776d6df8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/main/resources/myapp.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/test/java/myapp/CallbackClientTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-client/src/test/java/myapp/CallbackClientTestCase.java new file mode 100644 index 0000000000..fb2f6952c4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-service/README b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/README new file mode 100644 index 0000000000..2c65f745a6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-service/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/build.xml new file mode 100644 index 0000000000..e533c5f309 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/build.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/callback-ws-service.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-service/callback-ws-service.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/callback-ws-service.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/callback-ws-service.svg new file mode 100644 index 0000000000..ff0a1d307b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-service/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/pom.xml new file mode 100644 index 0000000000..87fa125e52 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-callback-ws-service + Apache Tuscany SCA Sample Callback Web Service + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/src/main/java/myserver/CallbackServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/src/main/java/myserver/CallbackServer.java new file mode 100644 index 0000000000..75ef05bc48 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-service/src/main/java/myserver/MyService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/src/main/java/myserver/MyService.java new file mode 100644 index 0000000000..1850eae1bc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-service/src/main/java/myserver/MyServiceCallback.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/src/main/java/myserver/MyServiceCallback.java new file mode 100644 index 0000000000..bf5f87a4f9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-service/src/main/java/myserver/MyServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/src/main/java/myserver/MyServiceImpl.java new file mode 100644 index 0000000000..25469def5c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-service/src/main/resources/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-service/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/src/main/resources/callbackws.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/src/main/resources/callbackws.composite new file mode 100644 index 0000000000..a09e638896 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callback-ws-service/src/test/java/myserver/CallbackServerTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callback-ws-service/src/test/java/myserver/CallbackServerTestCase.java new file mode 100644 index 0000000000..e87667cc3e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callbacks-jms/README b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/README new file mode 100644 index 0000000000..b5e130e2fc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callbacks-jms/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/build.xml new file mode 100644 index 0000000000..3a78845e99 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/pom.xml new file mode 100644 index 0000000000..8b406cd950 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/pom.xml @@ -0,0 +1,103 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-callbacks-jms + Apache Tuscany SCA Sample Callbacks with JMS + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6.2 + + + + junit + junit + 4.2 + test + + + + org.apache.activemq + activemq-core + 5.1.0 + test + + + backport-util-concurrent + backport-util-concurrent + 3.1 + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/CallbackJMSClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/CallbackJMSClient.java new file mode 100644 index 0000000000..c2e62ab8bd --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/CallbackJMSClient.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 callbacks; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; + +public class CallbackJMSClient { + + public static void main(String[] args) throws Exception { + + SCANodeFactory factory = SCANodeFactory.newInstance(); + SCANode node = factory.createSCANodeFromClassLoader("callbacks.composite", CallbackJMSClient.class.getClassLoader()); + node.start(); + + OrderServiceClient orderServiceClient = ((SCAClient)node).getService(OrderServiceClient.class, "ClientComponent"); + + // do something + orderServiceClient.doSomeOrdering(); + + // wait to give the service time to respond + Thread.sleep(500); + + node.stop(); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderCallback.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderCallback.java new file mode 100644 index 0000000000..775663cdff --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderRequest.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderRequest.java new file mode 100644 index 0000000000..69f5751379 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderResponse.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderResponse.java new file mode 100644 index 0000000000..882bcf8479 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderService.java new file mode 100644 index 0000000000..9f6d90577c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderServiceClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderServiceClient.java new file mode 100644 index 0000000000..3393ae5dca --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/java/callbacks/OrderServiceImpl.java new file mode 100644 index 0000000000..dd963bc1b0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callbacks-jms/src/main/resources/callbacks.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/resources/callbacks.composite new file mode 100644 index 0000000000..94dd29c45d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/resources/callbacks.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/resources/jndi.properties b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/main/resources/jndi.properties new file mode 100644 index 0000000000..698aeb1711 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/callbacks-jms/src/test/java/callbacks/CallbacksTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/callbacks-jms/src/test/java/callbacks/CallbacksTestCase.java new file mode 100644 index 0000000000..967fc42c64 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/chat-webapp/README b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/README new file mode 100644 index 0000000000..9e27166472 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/README @@ -0,0 +1,92 @@ +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. + +To save space, the WAR file isn't included in the binary distribution. You can +build it by following the instructions below in "Building And Running The Sample +Using Ant" or "Building And Running The Sample Using Maven". + +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. + +Note: There can be a delay before a browser client receives a message typed into +the chat. Some browsers receive pending messages immediately, some browsers +receive pending messages when a new message is sent, and some browsers receive +pending messages after a time delay of up to one minute. + +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 Ant +----------------------------------------- +With the binary distribution the sample can be built using Ant as +follows + +cd chat-webapp +ant package + +This should result in a war file (sample-chat-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-chat-webapp + +The port and hostname will of course vary depending on your local installation. + +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/tags/1.6.2-RC1/samples/chat-webapp/chat-webapp.png b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/chat-webapp.png new file mode 100644 index 0000000000..fdf540d243 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/chat-webapp.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/chat-webapp.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/chat-webapp.svg new file mode 100644 index 0000000000..b37c1dc590 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/chat-webapp.svg @@ -0,0 +1,187 @@ + + + + + + + + + + image/svg+xml + + + + + + + + store + + + DWR + + + DWR + + Catalog + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/pom.xml new file mode 100644 index 0000000000..d27655588d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/pom.xml @@ -0,0 +1,97 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-chat-webapp + war + Apache Tuscany SCA Sample Chat WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-binding-dwr + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + 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.6.2 + + + + generate + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/java/sample/ChatService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/java/sample/ChatService.java new file mode 100644 index 0000000000..ca90b8f579 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/chat-webapp/src/main/java/sample/ChatServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/java/sample/ChatServiceImpl.java new file mode 100644 index 0000000000..7d0bfb3307 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/chat-webapp/src/main/resources/chat.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/resources/chat.composite new file mode 100644 index 0000000000..c9ce95e2dc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/resources/chat.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..19b21549fb --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..d699725bd9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,40 @@ + + + + + + + org.apache.tuscany.sca + sample-chat-webapp + 1.6.2 + war + + + + + org.apache.axiom + org.apache.axis2 + org.apache.commons + org.jdom + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..97d91fec56 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/chat-webapp/src/main/webapp/chat.html b/sca-java-1.x/tags/1.6.2-RC1/samples/chat-webapp/src/main/webapp/chat.html new file mode 100644 index 0000000000..7a449a906a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/databinding-echo/README b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/README new file mode 100644 index 0000000000..67c1aa32d5 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/databinding-echo/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/build.xml new file mode 100644 index 0000000000..d1bffa6ff6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/databinding-echo.png b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/databinding-echo.png new file mode 100644 index 0000000000..afbbfff285 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/databinding-echo.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/databinding-echo.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/databinding-echo.svg new file mode 100644 index 0000000000..87964abf86 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/databinding-echo/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/pom.xml new file mode 100644 index 0000000000..9cde64f761 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/pom.xml @@ -0,0 +1,82 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + + sample-databinding-echo + Apache Tuscany SCA Sample Echo Data Binding + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-core-databinding + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + sample-binding-echo + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-interface-wsdl-xml + 1.6.2 + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/ComponentAImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/ComponentAImpl.java new file mode 100644 index 0000000000..5679614164 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/ComponentBImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/ComponentBImpl.java new file mode 100644 index 0000000000..ff8968837d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/Echo.java b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/Echo.java new file mode 100644 index 0000000000..25ecc90454 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/EchoDataBindingClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/EchoDataBindingClient.java new file mode 100644 index 0000000000..9ec3819899 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/Interface1.java b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/Interface1.java new file mode 100644 index 0000000000..70b450e358 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/Interface2.java b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/java/dbecho/Interface2.java new file mode 100644 index 0000000000..b62f1f425d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/databinding-echo/src/main/resources/EchoDataBinding.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/resources/EchoDataBinding.composite new file mode 100644 index 0000000000..30b77a6152 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/databinding-echo/src/main/resources/wsdl/echo.wsdl b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/main/resources/wsdl/echo.wsdl new file mode 100644 index 0000000000..ef2308aa73 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/databinding-echo/src/test/java/dbecho/EchoDataBindingTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/databinding-echo/src/test/java/dbecho/EchoDataBindingTestCase.java new file mode 100644 index 0000000000..43434d8cee --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/domain-management/README b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/README new file mode 100644 index 0000000000..eb31bb07ad --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/README @@ -0,0 +1,201 @@ +Domain Management Sample Tasks +============================== +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 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 run this sample to see what happens, open a command prompt, navigate +to this sample directory and run any of the sample domain management tasks +as follows: + +Running the Sample +------------------ + +1. List deployables in a contribution: + ------------------------------------ + + - This sample reads the SCA metadata for two sample contributions and prints the names of their deployable composites. + + - Use the following command to run the sample: + + ant runListDeployables + + - OR if you don't have ant, + + On windows do: + java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-domain-management.jar manager.ListDeployables + + On *nix do: + java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-domain-management.jar manager.ListDeployables + + - You should see the following output: + + Deployable: {http://store}store + +2. List contribution dependencies: + -------------------------------- + + - The sample reads the SCA metadata for two sample contributions and prints their dependencies. + + - Use the following command to run the sample: + + ant runListDependencies + + - OR if you don't have ant, + + On windows do: + java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-domain-management.jar manager.ListDependencies + + On *nix do: + java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-domain-management.jar manager.ListDependencies + + - You should see the following output: + + Contribution: store + dependency: assets + dependency: store + Contribution: assets + dependency: assets + +3. Add deployables to a domain composite and wire them: + ----------------------------------------------------- + + - The sample first reads the SCA metadata for three sample contributions, and resolve the artifacts contained in the contributions, + includes all their deployable composites in a composite model representing an SCA domain, and then + uses several composite builder utilities to configure 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. + + - Use the following command to run the sample: + + ant runWireComponents + + - OR if you don't have ant, + + On windows do: + java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-domain-management.jar manager.WireComponents + + On *nix do: + java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-domain-management.jar manager.WireComponents + + - You should see the following output: + + + + + + + + + + + + + + + + + + + + +4. List Components: + ----------------- + + - This sample reads the SCA metadata for two sample contributions, and 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 are actually resolved). + + - Use the following command to run the sample: + + ant runListComponents + + - OR if you don't have ant, + + On windows do: + java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-domain-management.jar manager.ListComponents + + On *nix do: + java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-domain-management.jar manager.ListComponents + + - You should see the following output: + + Deployable: {http://store}store + component: ShoppingCart + componentService: Cart + binding: class org.apache.tuscany.sca.binding.atom.impl.AtomBindingImpl - /ShoppingCart/Cart + implementation: services.ShoppingCartImpl + service: Cart + interface: services.Cart + + +Sample Overview +--------------- + +This sample demonstrates how to use some of the APIs for processing contributions. +These APIs are currently used under the covers in the domain manager. + +domain-management/ + src/ + main/ + java/ + manager/ + DistributeAndRunComponents.java + DistributeComponents.java + ListComponents.java + ListDependencies.java + ListDeployables.java + WireComponents.java + resources/ + test/ + java/ + services/ + Cart.java + Item.java + ShoppingCartClientImpl.java + ShoppingCartImpl.java + resources/ + assembly/ + assets.xml + client.xml + store.xml + assets/ + META-INF/ + sca-contribution.xml + client/ + META-INF/ + client.composite + store/ + META-INF/ + sca-contribution.xml + store.composite + build.xml + pom.xml + README + + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant as +follows: + +cd domain-management +ant compile +ant runListDeployables +ant runListDependencies +ant runWireComponents +ant runListComponents + + +Building the Sample Using Maven +------------------------------- + +cd domain-management +mvn + +** Please note that the mvn command will just build the sample and will install the required jar files into the Maven repository. +** In order to run the sample, please see the instructions - "Running the Sample" diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/pom.xml new file mode 100644 index 0000000000..37260c6c8e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/pom.xml @@ -0,0 +1,263 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../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.6.2 + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-contribution + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-contribution-xml + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-workspace + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-workspace-xml + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-workspace-impl + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-node + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-node-launcher + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-node-api + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-extensibility + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-monitor + 1.6.2 + + + + xerces + xercesImpl + 2.8.1 + + + + org.apache.tuscany.sca + tuscany-binding-atom + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-contribution-java + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-contribution-namespace + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-contribution-resource + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-xml + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-interface-java-xml + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-data-api + 1.6.2 + runtime + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.6.2 + + + + generate + + + true + + + target/sample-domain-management-assets.jar + + dir="target/test-classes/assets" + dir="target/test-classes" includes="services/**" + + + + target/sample-domain-management-client.jar + + dir="target/test-classes/client" + + + + target/sample-domain-management-store.jar + + dir="target/test-classes/store" + + + + + manager.ListDeployables + manager.ListDependencies + manager.WireComponents + manager.ListComponents + + + + + + + + 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/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java new file mode 100644 index 0000000000..83eff15a6a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/DistributeAndRunComponents.java @@ -0,0 +1,329 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package 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 ExtensionPointRegistry extensionPoints; + 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 + 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); + Map bindingMap = new HashMap(); + domainCompositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, + documentBuilderFactory, transformerFactory, contractMapper, monitor, bindingMap); + + // Create a node composite builder + nodeCompositeBuilder = new NodeCompositeBuilderImpl(assemblyFactory, scaBindingFactory, + documentBuilderFactory, transformerFactory, contractMapper, null, monitor, bindingMap); + } + + + public static void main(String[] args) throws Exception { + init(); + + // Create workspace model + Workspace workspace = workspaceFactory.createWorkspace(); + workspace.setModelResolver(new ExtensibleModelResolver(workspace, extensionPoints)); + + // 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/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/DistributeComponents.java b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/DistributeComponents.java new file mode 100644 index 0000000000..090cd02f43 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/DistributeComponents.java @@ -0,0 +1,289 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package 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.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.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 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 ExtensionPointRegistry extensionPoints; + 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 + 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); + Map bindingMap = new HashMap(); + domainCompositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, + documentBuilderFactory, transformerFactory, contractMapper, monitor, bindingMap); + + // Create a node composite builder + nodeCompositeBuilder = new NodeCompositeBuilderImpl(assemblyFactory, scaBindingFactory, + documentBuilderFactory, transformerFactory, contractMapper, null, monitor, bindingMap); + } + + + public static void main(String[] args) throws Exception { + init(); + + // Create workspace model + Workspace workspace = workspaceFactory.createWorkspace(); + workspace.setModelResolver(new ExtensibleModelResolver(workspace, extensionPoints)); + + // 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/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/ListComponents.java b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/ListComponents.java new file mode 100644 index 0000000000..7b3950833a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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 ExtensionPointRegistry extensionPoints; + 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 + 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, extensionPoints)); + + // 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/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/ListDependencies.java b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/ListDependencies.java new file mode 100644 index 0000000000..1bf8124682 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/ListDeployables.java b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/ListDeployables.java new file mode 100644 index 0000000000..f5f0b9c655 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/WireComponents.java b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/main/java/manager/WireComponents.java new file mode 100644 index 0000000000..54605acb05 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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 ExtensionPointRegistry extensionPoints; + 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 + 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, extensionPoints)); + + // 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 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 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/tags/1.6.2-RC1/samples/domain-management/src/test/java/services/Cart.java b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/java/services/Cart.java new file mode 100644 index 0000000000..9e6226d963 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/domain-management/src/test/java/services/Item.java b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/java/services/Item.java new file mode 100644 index 0000000000..81cefcdbef --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/domain-management/src/test/java/services/ShoppingCartClientImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/java/services/ShoppingCartClientImpl.java new file mode 100644 index 0000000000..c32853b3a9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/domain-management/src/test/java/services/ShoppingCartImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/java/services/ShoppingCartImpl.java new file mode 100644 index 0000000000..30abfe77a0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/domain-management/src/test/resources/assembly/assets.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/assembly/assets.xml new file mode 100644 index 0000000000..10693a89e6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/domain-management/src/test/resources/assembly/client.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/assembly/client.xml new file mode 100644 index 0000000000..5b34693bee --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/domain-management/src/test/resources/assembly/store.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/assembly/store.xml new file mode 100644 index 0000000000..d19b7eb161 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/domain-management/src/test/resources/assets/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/domain-management/src/test/resources/client/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/domain-management/src/test/resources/client/client.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/client/client.composite new file mode 100644 index 0000000000..1279b319c4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/client/client.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/store/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/domain-management/src/test/resources/store/store.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/store/store.composite new file mode 100644 index 0000000000..d4f18771d8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/domain-management/src/test/resources/store/store.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/README b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/README new file mode 100644 index 0000000000..560c6c4df6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/README @@ -0,0 +1,61 @@ +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. + +To save space, the WAR file isn't included in the binary distribution. You can +build it by following the instructions below in "Building And Running The Sample +Using Ant" or "Building And Running The Sample Using Maven". + +Once the web app is deployed use your browser to visit the following URL: + +http://localhost:8080/sample-feed-aggregator-webapp + +The port and hostname will of course vary depending on your local installation. + +You will then see the following displayed in your Web browser. + +http://{server-host}:{server-port}/sample-feed-aggregator-webapp/atomAggregator +http://{server-host}:{server-port}/sample-feed-aggregator-webapp/atomAggregator/atomsvc +http://{server-host}:{server-port}/sample-feed-aggregator-webapp/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/tags/1.6.2-RC1/samples/feed-aggregator-webapp/feed-aggregator-webapp.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/feed-aggregator-webapp/feed-aggregator-webapp.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/feed-aggregator-webapp.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/feed-aggregator-webapp.svg new file mode 100644 index 0000000000..a861a5c50f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/feed-aggregator-webapp/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/pom.xml new file mode 100644 index 0000000000..c11db2c091 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/pom.xml @@ -0,0 +1,108 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-feed-aggregator-webapp + war + Apache Tuscany SCA Sample Atom+RSS Feed Aggregator Webapp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-binding-rss-rome + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.6.2 + + + + generate + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/java/feed/AggregatorImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/java/feed/AggregatorImpl.java new file mode 100644 index 0000000000..855054003d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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, "UTF-8")); + } 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/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/java/feed/Sort.java b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/java/feed/Sort.java new file mode 100644 index 0000000000..dec073c36b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/java/feed/SortImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/java/feed/SortImpl.java new file mode 100644 index 0000000000..f7ead126a7 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/resources/FeedAggregator.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/resources/FeedAggregator.composite new file mode 100644 index 0000000000..a3d09db0f8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..036de16777 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..ade101bc83 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,40 @@ + + + + + + + org.apache.tuscany.sca + sample-feed-aggregator-webapp + 1.6.2 + war + + + + + org.apache.axiom + org.apache.axis2 + org.apache.commons + org.jdom + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/webapp/index.html b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/webapp/index.html new file mode 100644 index 0000000000..7220683a84 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator-webapp/src/main/webapp/index.html @@ -0,0 +1,33 @@ + + + + Apache Tuscany Feed Aggregator Sample + + + +

Apache Tuscany Feed Aggregator Sample

+

To read the aggregated feeds, point your Web browser to the following addresses or click on these links:

+ http://{server-host}:{server-port}/sample-feed-aggregator-webapp/atomAggregator
+ http://{server-host}:{server-port}/sample-feed-aggregator-webapp/atomAggregator/atomsvc (for the Atom service document)
+ http://{server-host}:{server-port}/sample-feed-aggregator-webapp/rssAggregator +

where {server-host} and {server-port} are the host and port of your web application server.

+ + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/README b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/README new file mode 100644 index 0000000000..8094bbf066 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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 browser. 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 - utility 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/tags/1.6.2-RC1/samples/feed-aggregator/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/build.xml new file mode 100644 index 0000000000..c7edbaf8a9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/feed-aggregator.png b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/feed-aggregator.png new file mode 100644 index 0000000000..c8fea8a7b8 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/feed-aggregator.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/feed-aggregator.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/feed-aggregator.svg new file mode 100644 index 0000000000..72fe6a00ac --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/feed-aggregator/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/pom.xml new file mode 100644 index 0000000000..ae16d4fa04 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/pom.xml @@ -0,0 +1,84 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../pom.xml + + sample-feed-aggregator + Apache Tuscany SCA Sample Atom+RSS Feed Aggregator + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-binding-rss-rome + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java new file mode 100644 index 0000000000..506701168e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java @@ -0,0 +1,199 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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) { + int x = 0; + } + } + if (atomFeed2 != null) { + try { + entries.addAll(atomFeed2.getFeed().getEntries()); + } catch (Exception e) { + int x = 0; + + } + } + if (rssFeed1 != null) { + try { + entries.addAll(atomFeed(rssFeed1.getFeed()).getEntries()); + } catch (Exception e) { + int x = 0; + + } + } + if (rssFeed2 != null) { + try { + entries.addAll(atomFeed(rssFeed2.getFeed()).getEntries()); + } catch (Exception e) { + int x = 0; + + } + } + + // 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, "UTF-8")); + } 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/tags/1.6.2-RC1/samples/feed-aggregator/src/main/java/feed/Sort.java b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/main/java/feed/Sort.java new file mode 100644 index 0000000000..dec073c36b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/feed-aggregator/src/main/java/feed/SortImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/main/java/feed/SortImpl.java new file mode 100644 index 0000000000..f7ead126a7 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/feed-aggregator/src/main/java/launch/LaunchFeedServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/main/java/launch/LaunchFeedServer.java new file mode 100644 index 0000000000..1c549f7cd2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/feed-aggregator/src/main/resources/FeedAggregator.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/main/resources/FeedAggregator.composite new file mode 100644 index 0000000000..018effc298 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/main/resources/FeedAggregator.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + RSS Aggregator Sample + + + + + true + + + + + + + + + + + + Atom Aggregator Sample + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTestCase.java new file mode 100644 index 0000000000..3ee44c4c0e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/feed-aggregator/src/test/java/feed/FeedAggregatorTestCase.java @@ -0,0 +1,397 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package feed; + +import java.io.IOException; +import java.io.Reader; +import java.net.Socket; +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.apache.abdera.Abdera; +import org.apache.abdera.model.Base; +import org.apache.abdera.model.Collection; +import org.apache.abdera.model.Document; +import org.apache.abdera.model.Entry; +import org.apache.abdera.model.Feed; +import org.apache.abdera.parser.Parser; +import org.apache.abdera.protocol.Response.ResponseType; +import org.apache.abdera.protocol.client.AbderaClient; +import org.apache.abdera.protocol.client.ClientResponse; +import org.apache.abdera.protocol.client.RequestOptions; +import org.apache.abdera.writer.Writer; +import org.apache.abdera.writer.WriterFactory; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Tests use of server provided feed entity tags for Atom binding in Tuscany. + * Tests conditional gets (e.g. get if-none-match) or conditional posts (post + * if-match) using entity tags and last modified entries in headers. Uses the + * SCA provided Provider composite to act as a server. Uses the Abdera provided + * Client to act as a client. + */ +public class FeedAggregatorTestCase { + 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"); // RFC822 date time + + @BeforeClass + public static void init() throws Exception { + if (!internetConnected()) { + // no internet connection + return; + } + 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"); + if (scaProviderDomain != null) { + scaProviderDomain.close(); + } + } + + @Test + public void testPrelim() throws Exception { + if (scaProviderDomain == null) { + // no internet connection + return; + } + Assert.assertNotNull(scaProviderDomain); + Assert.assertNotNull(client); + } + + @Test + public void testFeedBasics() throws Exception { + if (scaProviderDomain == null) { + // no internet connection + return; + } + System.out.println(">>>FeedAggregatorTest.testFeedBasics"); + RequestOptions opts = new RequestOptions(); + // Normal feed request + ClientResponse res = client.get(providerURI, opts); + Assert.assertNotNull(res); + try { + // Assert feed provided since no predicates + Assert.assertEquals(200, res.getStatus()); + Assert.assertEquals(ResponseType.SUCCESS, res.getType()); + // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", + // " ", res ); + + // 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 { + if (scaProviderDomain == null) { + // no internet connection + return; + } + 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 { + if (scaProviderDomain == null) { + // no internet connection + return; + } + 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 412 - Feed not provided since feed is modified + // since. + Assert.assertEquals(412, 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; + } + + private static boolean internetConnected() { + try { + // see whether an internet connection is available + Socket testInternet = new Socket("tuscany.apache.org", 80); + testInternet.close(); + + // internet connection available + return true; + + } catch (Exception e) { + // no internet connection + System.out.println("Unable to run test because no internet connection available"); + return false; + } + } +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/README b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/README new file mode 100644 index 0000000000..36d5dedb16 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/README @@ -0,0 +1,145 @@ +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 run + +OR if you don't have ant, on Windows do + +unzip ..\..\lib\ode-dao-jpa-ojpa-derby-1.1.zip -d target\database +unzip target\sample-helloworld-bpel.jar -d target\classes +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\classes;target\database helloworld.BPELClient + +and on *nix do + +unzip ../../lib/ode-dao-jpa-ojpa-derby-1.1.zip -d target/database +unzip target/sample-helloworld-bpel.jar -d 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. + +Unlike other samples that are run from a jar file, this sample is run from the +target/classes directory because Tuscany doesn't currently support running +a BPEL process file contained within a jar (see TUSCANY-1994). + +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 exercises +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/tags/1.6.2-RC1/samples/helloworld-bpel/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/build.xml new file mode 100644 index 0000000000..8a3edcf60a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/build.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/helloworld-bpel.png b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/helloworld-bpel.png new file mode 100644 index 0000000000..5f53a3c5d1 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/helloworld-bpel.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/helloworld-bpel.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/helloworld-bpel.svg new file mode 100644 index 0000000000..5a98f1a07c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-bpel/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/pom.xml new file mode 100644 index 0000000000..84387d9028 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/pom.xml @@ -0,0 +1,209 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-helloworld-bpel + Apache Tuscany SCA Sample HelloWorld BPEL + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-bpel-ode + 1.6.2 + runtime + + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.1.1 + + + backport-util-concurrent + backport-util-concurrent + + + + + backport-util-concurrent + backport-util-concurrent + 3.1 + + + + xerces + xercesImpl + 2.8.1 + + + + junit + junit + 4.5 + test + + + + org.apache.tuscany.sca + tuscany-wsdl2java + 1.6.2 + + + + org.apache.tuscany.sdo + tuscany-sdo-tools + 1.1.1 + + + + org.codehaus.woodstox + wstx-asl + 3.2.4 + 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.6.2 + + + + ${basedir}/src/main/resources/helloworld.wsdl + + + generate + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.java new file mode 100644 index 0000000000..1826c885c4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/resources/helloworld.bpel b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/resources/helloworld.bpel new file mode 100644 index 0000000000..a88aa7960c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/resources/helloworld.bpel @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + concat($tmpVar,' World') + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/resources/helloworld.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/resources/helloworld.composite new file mode 100644 index 0000000000..b4623b5c2d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/resources/helloworld.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/resources/helloworld.wsdl b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/resources/helloworld.wsdl new file mode 100644 index 0000000000..46cf381577 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/resources/log4j.properties b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/main/resources/log4j.properties new file mode 100644 index 0000000000..8649a71550 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java new file mode 100644 index 0000000000..1caaa78878 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/README b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/README new file mode 100644 index 0000000000..384c192e29 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/README @@ -0,0 +1,108 @@ +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 your web application server. + +To save space, the WAR file isn't included in the binary distribution. You can +build it by following the instructions below in "Building And Running The Sample +Using Ant" or "Building And Running The Sample Using Maven". + +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/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/build-dojo.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/build-dojo.xml new file mode 100644 index 0000000000..1bffc6c6cc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/build-dojo.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/build.xml new file mode 100644 index 0000000000..4f7d6c9859 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/build.xml @@ -0,0 +1,67 @@ + + +]> + + + + &buildDependency; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/helloworld-jsonrpc.png b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/helloworld-jsonrpc.png new file mode 100644 index 0000000000..57f90aed01 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/helloworld-jsonrpc.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/helloworld-jsonrpc.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/helloworld-jsonrpc.svg new file mode 100644 index 0000000000..d5c3bc5d3e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/pom.xml new file mode 100644 index 0000000000..6cb6d0b877 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/pom.xml @@ -0,0 +1,156 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-helloworld-dojo-webapp + war + Apache Tuscany SCA Sample HelloWorld DOJO WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.6.2 + runtime + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + org.dojotoolkit + dojo + 1.3.0 + zip + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + org.apache.maven.plugins + maven-antrun-plugin + + + + ant + ant-trax + 1.6.5 + + + + + copy-dojo-files + generate-resources + + run + + + + + + + + + + + + clean-dojo-files + package + + run + + + + + + + + + + + + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.6.2 + + + + true + + + generate + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/java/helloworldjsonrpc/HelloWorldService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/java/helloworldjsonrpc/HelloWorldService.java new file mode 100644 index 0000000000..3d8ea24f04 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..e205f4da9b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/resources/jsonrpc.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/resources/jsonrpc.composite new file mode 100644 index 0000000000..e895ab455d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/resources/jsonrpc.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/HelloWorldJSONRPC.html b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/HelloWorldJSONRPC.html new file mode 100644 index 0000000000..0a49ee5c46 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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 invoke the getGreetings + method of the HelloWorldService object.

+
RequestResponse

+ +
+
None Yet.
+
+
Dojo Debug:
+
+ + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..b5e24d40f6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..a3810fe3b9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,40 @@ + + + + + + + org.apache.tuscany.sca + sample-helloworld-dojo-webapp + 1.6.2 + war + + + + + org.apache.axiom + org.apache.axis2 + org.apache.commons + org.jdom + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/style.css b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-dojo-webapp/src/main/webapp/style.css new file mode 100644 index 0000000000..1071583264 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-erlang-reference/README b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/README new file mode 100644 index 0000000000..e0c1a5c89f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/README @@ -0,0 +1,127 @@ +Hello World Erlang Reference Sample +=================================== +This sample demonstrates an SCA reference that uses a Erlang binding + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +In order to run Erlang samples you need to have Erlang/OTP distribution installed - +epmd binary is required in your system path. See http://erlang.org for downloads. + +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-erlang-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-erlang-service.jar helloworld.HelloWorldServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-erlang-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-erlang-reference.jar helloworld.HelloWorldErlangClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-erlang-reference.jar helloworld.HelloWorldErlangClient + + +Sample Overview +--------------- +The sample provides a component that has a reference with a Erlang binding. +The binding refers to Erlang module and communicates with a service +exposed by the helloworld-service-erlang sample. + +helloworld-erlang-reference/ + src/ + main/ + java/ + helloworld/ + HelloWorldImpl - HelloWorld service implementation + HelloWorldService.java - interface description for + HelloWorldServiceComponent + HelloWorldServiceComponent.java - component implementation + HelloWorldErlangClient.java - starts the SCA Runtime and + deploys the helloworldwserlangclient + .composite. It then calls the + HelloWorldServiceComponent + resources/ + helloworlderlangreference.composite - the SCA assembly for this sample + helloworlderlangservice.composite - the SCA assembly for the server + that is used by the JUnit tests + logging.properties - log4j configuration file + test/ + java/ + helloworld/ + HelloWorldErlangClientTestCase.java - JUnit test case + dynaignore/ - internal Java classes for ignoring test + in case of missing Erlang/OTP distribution + + 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-erlang-service sample. Take a look at the README in that sample +and you will see you need the following commands + +cd helloworld-erlang-service +ant run + +Once done you can now compile and run this sample using the following commands; + +cd helloworld-erlang-reference +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] 2009-05-26 12:03:54 org.apache.tuscany.sca.node.impl.NodeImpl + [java] INFO: Creating node: helloworlderlangreference.composite + [java] 2009-05-26 12:03:55 org.apache.tuscany.sca.node.impl.NodeImpl configureNode + [java] 2009-05-26 12:03:56 org.apache.tuscany.sca.node.impl.NodeImpl configureNode + [java] 2009-05-26 12:03:56 org.apache.tuscany.sca.node.impl.NodeImpl start + [java] INFO: Starting node: helloworlderlangreference.composite + [java] Hello World + [java] 2009-05-26 12:03:56 org.apache.tuscany.sca.node.impl.NodeImpl stop + [java] INFO: Stopping node: helloworlderlangreference.composite + +BUILD SUCCESSFUL + + +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- +erlang-service sample first as the JUnit test does this for you. + +cd helloworld-erlang-reference +mvn + +You should see the following output from the test phase. + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.569 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/tags/1.6.2-RC1/samples/helloworld-erlang-reference/helloworld-reference.png b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/helloworld-reference.png new file mode 100644 index 0000000000..5c80743d14 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/helloworld-reference.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/helloworld-reference.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/helloworld-reference.svg new file mode 100644 index 0000000000..992d56875b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/helloworld-reference.svg @@ -0,0 +1,153 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + helloworlderlangreference + + HelloWorldServiceComponent + + HelloWorldService ReferenceErlang + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/pom.xml new file mode 100644 index 0000000000..9ba841a48f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/pom.xml @@ -0,0 +1,106 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-helloworld-erlang-reference + Apache Tuscany SCA Sample HelloWorld Erlang Reference + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-erlang-runtime + 1.6.2 + + + + junit + junit + 4.5 + test + + + + org.apache.activemq + activemq-all + 5.2.0 + test + + + org.apache.activemq + activemq-web-demo + + + + + backport-util-concurrent + backport-util-concurrent + 3.1 + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.6.2 + + + + generate + + + helloworld.HelloWorldErlangClient + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/java/helloworld/HelloWorldErlangClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/java/helloworld/HelloWorldErlangClient.java new file mode 100644 index 0000000000..9b881b77ff --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/java/helloworld/HelloWorldErlangClient.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 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 HelloWorldErlangClient { + + public final static void main(String[] args) throws Exception { + SCADomain scaDomain = SCADomain.newInstance("helloworlderlangreference.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/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..4cdcc1fd0b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/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/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..c0259c6e07 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-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/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/java/helloworld/HelloWorldServiceComponent.java new file mode 100644 index 0000000000..6c833ab888 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/java/helloworld/HelloWorldServiceComponent.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 helloworld; + +/** + * The HelloWorld service implementation + */ +public class HelloWorldServiceComponent implements HelloWorldService { + + HelloWorldService helloWorldService; + + public String getGreetings(String name) { + return helloWorldService.getGreetings(name); + } + + public HelloWorldService getHelloWorldService() { + return helloWorldService; + } + + public void setHelloWorldService(HelloWorldService helloWorldService) { + this.helloWorldService = helloWorldService; + } +} \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/resources/helloworlderlangreference.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/resources/helloworlderlangreference.composite new file mode 100644 index 0000000000..5c2e8786f1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/resources/helloworlderlangreference.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/resources/helloworlderlangservice.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/resources/helloworlderlangservice.composite new file mode 100644 index 0000000000..d2ff8455d8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/resources/helloworlderlangservice.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/resources/logging.properties b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/main/resources/logging.properties new file mode 100644 index 0000000000..a2a4067921 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-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: 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/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/test/java/helloworld/HelloWorldErlangClientTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/test/java/helloworld/HelloWorldErlangClientTestCase.java new file mode 100644 index 0000000000..0776892414 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/test/java/helloworld/HelloWorldErlangClientTestCase.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 helloworld; + +import java.io.InputStream; +import java.io.IOException; + +import helloworld.dynaignore.IgnorableRunner; +import helloworld.dynaignore.IgnoreTest; +import junit.framework.Assert; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * Test case for helloworld Erlang client + */ +@RunWith(IgnorableRunner.class) +public class HelloWorldErlangClientTestCase { + + private static final String EPMD_COMMAND = "epmd"; + + @Test + public void testClient() { + Process epmdProcess = null; + try { + epmdProcess = Runtime.getRuntime().exec(EPMD_COMMAND); + } catch (IOException e) { + System.out + .println("Cannot proceed - exception while executing " + + EPMD_COMMAND + + ": " + + e.getMessage() + + ". Valid and working Erlang/OTP distribution is required."); + throw new IgnoreTest(); + } + startReaderThread(epmdProcess.getInputStream()); + startReaderThread(epmdProcess.getErrorStream()); + + SCADomain scaServiceDomain = SCADomain + .newInstance("helloworlderlangservice.composite"); + SCADomain scaClientDomain = SCADomain + .newInstance("helloworlderlangreference.composite"); + HelloWorldService helloWorldService = scaClientDomain.getService( + HelloWorldService.class, "HelloWorldServiceComponent"); + String msg = helloWorldService.getGreetings("Smith"); + Assert.assertEquals("Hello Smith", msg); + scaClientDomain.close(); + scaServiceDomain.close(); + + epmdProcess.destroy(); + } + + private static void startReaderThread(final InputStream stream) { + Thread readerThread = new Thread() { + public void run() { + try { + byte[] buf = new byte[100]; + while (true) { + stream.read(buf); + } + } catch (Exception e) { + return; + } + } + }; + readerThread.start(); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/test/java/helloworld/dynaignore/IgnorableRunner.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/test/java/helloworld/dynaignore/IgnorableRunner.java new file mode 100644 index 0000000000..6943c1df80 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/test/java/helloworld/dynaignore/IgnorableRunner.java @@ -0,0 +1,139 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package helloworld.dynaignore; + +import org.junit.runner.Description; +import org.junit.runner.Result; +import org.junit.runner.Runner; +import org.junit.runner.notification.Failure; +import org.junit.runner.notification.RunListener; +import org.junit.runner.notification.RunNotifier; +import org.junit.runner.notification.StoppedByUserException; +import org.junit.runners.BlockJUnit4ClassRunner; +import org.junit.runners.model.InitializationError; + +/** + * @version $Rev$ $Date$ + */ +public class IgnorableRunner extends Runner { + + private static final class Notifier extends RunNotifier { + private final RunNotifier notifier; + + public Notifier(final RunNotifier notifier) { + this.notifier = notifier; + } + + public void addFirstListener(final RunListener listener) { + notifier.addFirstListener(listener); + } + + public void addListener(final RunListener listener) { + notifier.addListener(listener); + } + + @Override + public boolean equals(final Object obj) { + return notifier.equals(obj); + } + + @Override + public void fireTestFailure(final Failure failure) { + if (failure.getException().getClass() == IgnoreTest.class) { + notifier.fireTestIgnored(failure.getDescription()); + } else { + notifier.fireTestFailure(failure); + } + } + + @Override + public void fireTestFinished(final Description description) { + notifier.fireTestFinished(description); + } + + @Override + public void fireTestIgnored(final Description description) { + notifier.fireTestIgnored(description); + } + + @Override + public void fireTestRunFinished(final Result result) { + notifier.fireTestRunFinished(result); + } + + @Override + public void fireTestRunStarted(final Description description) { + notifier.fireTestRunStarted(description); + } + + @Override + public void fireTestStarted(final Description description) + throws StoppedByUserException { + notifier.fireTestStarted(description); + } + + @Override + public int hashCode() { + return notifier.hashCode(); + } + + @Override + public void pleaseStop() { + notifier.pleaseStop(); + } + + @Override + public void removeListener(final RunListener listener) { + notifier.removeListener(listener); + } + + public void testAborted(final Description description, + final Throwable cause) { + ((Notifier) notifier).testAborted(description, cause); + } + + @Override + public String toString() { + return notifier.toString(); + } + + } + + Runner runner = null; + + public IgnorableRunner(Class testClass) { + try { + runner = new BlockJUnit4ClassRunner(testClass); + } catch (InitializationError e) { + e.printStackTrace(); + } + } + + @Override + public Description getDescription() { + return runner.getDescription(); + } + + @Override + public void run(RunNotifier notifier) { + runner.run(new Notifier(notifier)); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/test/java/helloworld/dynaignore/IgnoreTest.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/test/java/helloworld/dynaignore/IgnoreTest.java new file mode 100644 index 0000000000..99d961bdea --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-reference/src/test/java/helloworld/dynaignore/IgnoreTest.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.dynaignore; + +/** + * @version $Rev$ $Date$ + */ +public final class IgnoreTest extends Error { + + private static final long serialVersionUID = 1L; + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/README b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/README new file mode 100644 index 0000000000..ed21c91098 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/README @@ -0,0 +1,111 @@ +Hello World Erlang Service Sample +================================= +This sample demonstrates an SCA service that uses a Erlang binding + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +In order to run Erlang samples you need to have Erlang/OTP distribution installed - +epmd binary is required in your system path. See http://erlang.org for downloads. + +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-erlang-service.jar helloworld.HelloWorldServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-erlang-service.jar helloworld.HelloWorldServer + +Now the server is started you can use the helloworld-erlang-reference sample to +exercise it. + +Sample Overview +--------------- +The sample provides a single component that is wired to a service with a +Erlang binding. + +helloworld-erlang-service/ + src/ + main/ + java/ + helloworld/ + HelloWorldService.java - interface description for + HelloWorldServiceComponent + HelloWorldImpl.java - component implementation + HelloWorldServer.java - starts the SCA Runtime and + deploys the helloworlderlangservice + .composite and then waits for the + service to be called via Erlang + resources/ + helloworlderlangservice.composite - the SCA assembly for this sample + + test/ + java/ + helloworld/ + HelloWorldErlangServerTestCase.java - JUnit test case + dynaignore/ - internal Java classes for ignoring test + in case of missing Erlang/OTP distribution + 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-erlang-service +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] EPMD server started + [java] 2009-05-26 11:59:07 org.apache.tuscany.sca.node.impl.NodeImpl + [java] INFO: Creating node: helloworlderlangservice.composite + [java] 2009-05-26 11:59:08 org.apache.tuscany.sca.node.impl.NodeImpl configureNode + [java] 2009-05-26 11:59:08 org.apache.tuscany.sca.node.impl.NodeImpl configureNode + [java] 2009-05-26 11:59:08 org.apache.tuscany.sca.node.impl.NodeImpl start + [java] INFO: Starting node: helloworlderlangservice.composite + [java] HelloWorld server started (press enter to shutdown) + + +As this point the SCA service is exposed as a Erlang module via Erlang RPC which is +started automatically by the SCA runtime. To stop the server just press +enter. + +To exercise the service run up the helloworld-erlang-reference sample. Take a look at +the README in that sample and you will see you need the following commands + +cd helloworld-erlang-reference +ant run + +Building Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built +using Maven as follows. + +cd helloworld-erlang-service +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/tags/1.6.2-RC1/samples/helloworld-erlang-service/helloworld-service.png b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/helloworld-service.png new file mode 100644 index 0000000000..506c258274 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/helloworld-service.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/helloworld-service.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/helloworld-service.svg new file mode 100644 index 0000000000..c3a89c6cd2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/helloworld-service.svg @@ -0,0 +1,148 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + helloworld + + HelloWorldServiceComponent + HelloWorldServiceErlang + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/pom.xml new file mode 100644 index 0000000000..d059ccedb3 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/pom.xml @@ -0,0 +1,89 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-helloworld-erlang-service + Apache Tuscany SCA Sample HelloWorld Erlang Service + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + compile + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-erlang-runtime + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.6.2 + + + + generate + + + helloworld.HelloWorldServer + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..4cdcc1fd0b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-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/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/main/java/helloworld/HelloWorldServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/main/java/helloworld/HelloWorldServer.java new file mode 100644 index 0000000000..2e632c00fc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/main/java/helloworld/HelloWorldServer.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 java.io.InputStream; +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 { + + private static final String EPMD_COMMAND = "epmd"; + + public static void main(String[] args) { + try { + Process process = null; + try { + process = Runtime.getRuntime().exec(EPMD_COMMAND); + } catch (IOException e) { + System.out + .println("Cannot proceed - exception while executing " + + EPMD_COMMAND + + ": " + + e.getMessage() + + ". Valid and working Erlang/OTP distribution is required."); + } + if (process != null) { + startReaderThread(process.getInputStream()); + startReaderThread(process.getErrorStream()); + System.out.println("EPMD server started"); + + SCADomain scaDomain = SCADomain + .newInstance("helloworlderlangservice.composite"); + System.out + .println("HelloWorld server started (press enter to shutdown)"); + System.in.read(); + scaDomain.close(); + System.out.println("HelloWorld server stopped"); + + process.destroy(); + System.out.println("EPMD server stopped"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static void startReaderThread(final InputStream stream) { + Thread readerThread = new Thread() { + public void run() { + try { + byte[] buf = new byte[100]; + while (true) { + stream.read(buf); + } + } catch (Exception e) { + return; + } + } + }; + readerThread.start(); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..4b019b21bf --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-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/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/main/resources/helloworlderlangservice.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/main/resources/helloworlderlangservice.composite new file mode 100644 index 0000000000..1e0c57c74d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/main/resources/helloworlderlangservice.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/test/java/helloworld/HelloWorldErlangServerTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/test/java/helloworld/HelloWorldErlangServerTestCase.java new file mode 100644 index 0000000000..a071e153d2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/test/java/helloworld/HelloWorldErlangServerTestCase.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 helloworld; + +import java.io.InputStream; +import java.io.IOException; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; + +import helloworld.dynaignore.IgnorableRunner; +import helloworld.dynaignore.IgnoreTest; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * Tests that the helloworld server is available + */ +@RunWith(IgnorableRunner.class) +public class HelloWorldErlangServerTestCase { + + private static final String EPMD_COMMAND = "epmd"; + + @Test + public void testServiceCall() { + Process epmdProcess = null; + try { + epmdProcess = Runtime.getRuntime().exec(EPMD_COMMAND); + } catch (IOException e) { + System.out + .println("Cannot proceed - exception while executing " + + EPMD_COMMAND + + ": " + + e.getMessage() + + ". Valid and working Erlang/OTP distribution is required."); + throw new IgnoreTest(); + } + startReaderThread(epmdProcess.getInputStream()); + startReaderThread(epmdProcess.getErrorStream()); + + SCADomain scaDomain = SCADomain + .newInstance("helloworlderlangservice.composite"); + HelloWorldService helloWorldService = scaDomain.getService( + HelloWorldService.class, + "HelloWorldServiceComponent/HelloWorldService"); + assertNotNull(helloWorldService); + assertEquals("Hello Smith", helloWorldService.getGreetings("Smith")); + scaDomain.close(); + + epmdProcess.destroy(); + } + + private static void startReaderThread(final InputStream stream) { + Thread readerThread = new Thread() { + public void run() { + try { + byte[] buf = new byte[100]; + while (true) { + stream.read(buf); + } + } catch (Exception e) { + return; + } + } + }; + readerThread.start(); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/test/java/helloworld/dynaignore/IgnorableRunner.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/test/java/helloworld/dynaignore/IgnorableRunner.java new file mode 100644 index 0000000000..6943c1df80 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/test/java/helloworld/dynaignore/IgnorableRunner.java @@ -0,0 +1,139 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package helloworld.dynaignore; + +import org.junit.runner.Description; +import org.junit.runner.Result; +import org.junit.runner.Runner; +import org.junit.runner.notification.Failure; +import org.junit.runner.notification.RunListener; +import org.junit.runner.notification.RunNotifier; +import org.junit.runner.notification.StoppedByUserException; +import org.junit.runners.BlockJUnit4ClassRunner; +import org.junit.runners.model.InitializationError; + +/** + * @version $Rev$ $Date$ + */ +public class IgnorableRunner extends Runner { + + private static final class Notifier extends RunNotifier { + private final RunNotifier notifier; + + public Notifier(final RunNotifier notifier) { + this.notifier = notifier; + } + + public void addFirstListener(final RunListener listener) { + notifier.addFirstListener(listener); + } + + public void addListener(final RunListener listener) { + notifier.addListener(listener); + } + + @Override + public boolean equals(final Object obj) { + return notifier.equals(obj); + } + + @Override + public void fireTestFailure(final Failure failure) { + if (failure.getException().getClass() == IgnoreTest.class) { + notifier.fireTestIgnored(failure.getDescription()); + } else { + notifier.fireTestFailure(failure); + } + } + + @Override + public void fireTestFinished(final Description description) { + notifier.fireTestFinished(description); + } + + @Override + public void fireTestIgnored(final Description description) { + notifier.fireTestIgnored(description); + } + + @Override + public void fireTestRunFinished(final Result result) { + notifier.fireTestRunFinished(result); + } + + @Override + public void fireTestRunStarted(final Description description) { + notifier.fireTestRunStarted(description); + } + + @Override + public void fireTestStarted(final Description description) + throws StoppedByUserException { + notifier.fireTestStarted(description); + } + + @Override + public int hashCode() { + return notifier.hashCode(); + } + + @Override + public void pleaseStop() { + notifier.pleaseStop(); + } + + @Override + public void removeListener(final RunListener listener) { + notifier.removeListener(listener); + } + + public void testAborted(final Description description, + final Throwable cause) { + ((Notifier) notifier).testAborted(description, cause); + } + + @Override + public String toString() { + return notifier.toString(); + } + + } + + Runner runner = null; + + public IgnorableRunner(Class testClass) { + try { + runner = new BlockJUnit4ClassRunner(testClass); + } catch (InitializationError e) { + e.printStackTrace(); + } + } + + @Override + public Description getDescription() { + return runner.getDescription(); + } + + @Override + public void run(RunNotifier notifier) { + runner.run(new Notifier(notifier)); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/test/java/helloworld/dynaignore/IgnoreTest.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/test/java/helloworld/dynaignore/IgnoreTest.java new file mode 100644 index 0000000000..99d961bdea --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-erlang-service/src/test/java/helloworld/dynaignore/IgnoreTest.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.dynaignore; + +/** + * @version $Rev$ $Date$ + */ +public final class IgnoreTest extends Error { + + private static final long serialVersionUID = 1L; + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/README b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/README new file mode 100644 index 0000000000..8db50dd195 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/README @@ -0,0 +1,94 @@ +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 your web application server. + +To save space, the WAR file isn't included in the binary distribution. You can +build it by following the instructions below in "Building And Running The Sample +Using Ant" or "Building And Running The Sample Using Maven". + +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/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/helloworld-jsonrpc.png b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/helloworld-jsonrpc.png new file mode 100644 index 0000000000..57f90aed01 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/helloworld-jsonrpc.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/helloworld-jsonrpc.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/helloworld-jsonrpc.svg new file mode 100644 index 0000000000..6ef1f438fb --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/pom.xml new file mode 100644 index 0000000000..52e6ec26cd --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/pom.xml @@ -0,0 +1,103 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-helloworld-jsonrpc-webapp + war + Apache Tuscany SCA Sample HelloWorld JSON-RPC WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.6.2 + runtime + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.6.2 + + + + generate + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/java/helloworldjsonrpc/HelloWorldService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/java/helloworldjsonrpc/HelloWorldService.java new file mode 100644 index 0000000000..3d8ea24f04 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..35fd00fabd --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/resources/jsonrpc.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/resources/jsonrpc.composite new file mode 100644 index 0000000000..e895ab455d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/resources/jsonrpc.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/HelloWorldJSONRPC.html b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/HelloWorldJSONRPC.html new file mode 100644 index 0000000000..75dd9050fa --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..36ee041cf1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..11683ea4ef --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,40 @@ + + + + + + + org.apache.tuscany.sca + sample-helloworld-jsonrpc-webapp + 1.6.2 + war + + + + + org.apache.axiom + org.apache.axis2 + org.apache.commons + org.jdom + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/style.css b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-jsonrpc-webapp/src/main/webapp/style.css new file mode 100644 index 0000000000..1071583264 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-reference-jms/README b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/README new file mode 100644 index 0000000000..184e67a239 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-reference-jms/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/build.xml new file mode 100644 index 0000000000..ff53ca2fc7 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/helloworld-reference.png b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/helloworld-reference.png new file mode 100644 index 0000000000..ab80b1f91c Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/helloworld-reference.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/helloworld-reference.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/helloworld-reference.svg new file mode 100644 index 0000000000..40f4e8f271 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-reference-jms/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/pom.xml new file mode 100644 index 0000000000..4e1099eee9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/pom.xml @@ -0,0 +1,103 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-helloworld-reference-jms + Apache Tuscany SCA Sample HelloWorld Reference JMS + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6.2 + + + + org.apache.tuscany.sca + sample-helloworld-service-jms + 1.6.2 + test + + + + junit + junit + 4.5 + test + + + + org.apache.activemq + activemq-all + 5.2.0 + test + + + org.apache.activemq + activemq-web-demo + + + + + backport-util-concurrent + backport-util-concurrent + 3.1 + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..4cdcc1fd0b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldJmsClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldJmsClient.java new file mode 100644 index 0000000000..5bec27a137 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..c0259c6e07 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/java/helloworld/HelloWorldServiceComponent.java new file mode 100644 index 0000000000..27cef47677 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/resources/helloworldjmsreference.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/resources/helloworldjmsreference.composite new file mode 100644 index 0000000000..3cf1104562 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/resources/helloworldjmsreference.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/resources/helloworldjmsservice.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/resources/helloworldjmsservice.composite new file mode 100644 index 0000000000..e692ef8e4c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/resources/helloworldjmsservice.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/resources/logging.properties b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/resources/logging.properties new file mode 100644 index 0000000000..a2a4067921 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..e0ea596dd3 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/test/java/helloworld/HelloWorldJmsClientTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-reference-jms/src/test/java/helloworld/HelloWorldJmsClientTestCase.java new file mode 100644 index 0000000000..f5380d9ccd --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-service-jms/README b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/README new file mode 100644 index 0000000000..49feabaa07 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-service-jms/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/build.xml new file mode 100644 index 0000000000..0b5fd56208 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/helloworld-service.png b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/helloworld-service.png new file mode 100644 index 0000000000..ef27c71f54 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/helloworld-service.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/helloworld-service.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/helloworld-service.svg new file mode 100644 index 0000000000..dd7a9dd87d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/helloworld-service.svg @@ -0,0 +1,139 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworld + + HelloWorldServiceComponent + HelloWorldServiceJMS + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/pom.xml new file mode 100644 index 0000000000..f3e7b246b7 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/pom.xml @@ -0,0 +1,96 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-helloworld-service-jms + Apache Tuscany SCA Sample HelloWorld Service JMS + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + compile + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6.2 + + + + junit + junit + 4.5 + test + + + + org.apache.activemq + activemq-all + 5.2.0 + + + org.apache.activemq + activemq-web-demo + + + + + backport-util-concurrent + backport-util-concurrent + 3.1 + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..a81a0d79ac --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldImpl.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 HelloWorldImpl implements HelloWorldService { + + public String getGreetings(String name) { + System.out.println("Got greeting " + name + " at server"); + return "Hello " + name; + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldServer.java new file mode 100644 index 0000000000..d4ea391a00 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..4b019b21bf --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/resources/definitions.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/resources/definitions.xml new file mode 100644 index 0000000000..8c881ab0bb --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/resources/helloworldjmsservice.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/resources/helloworldjmsservice.composite new file mode 100644 index 0000000000..3135cdc320 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/resources/helloworldjmsservice.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..3f9e00689e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/test/java/helloworld/HelloWorldJmsServerTestCaseOff.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-service-jms/src/test/java/helloworld/HelloWorldJmsServerTestCaseOff.java new file mode 100644 index 0000000000..7930f98716 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/README b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/README new file mode 100644 index 0000000000..abf10ef1f2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/build.xml new file mode 100644 index 0000000000..e18e984c76 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/helloworld-ws-reference.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/helloworld-ws-reference.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/helloworld-ws-reference.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/helloworld-ws-reference.svg new file mode 100644 index 0000000000..333ad53e0a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/pom.xml new file mode 100644 index 0000000000..a9072f574d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/pom.xml @@ -0,0 +1,92 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-helloworld-ws-reference-jms + Apache Tuscany SCA Sample HelloWorld Web Service Reference JMS + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + runtime + + + + org.apache.tuscany.sca + sample-helloworld-ws-service-jms + 1.6.2 + test + + + + junit + junit + 4.5 + test + + + + org.apache.activemq + activemq-all + 5.2.0 + test + + + org.apache.activemq + activemq-web-demo + + + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldJmsClient.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjms.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjms.composite new file mode 100644 index 0000000000..d029ba3e1c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjms.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjmsclient.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjmsclient.composite new file mode 100644 index 0000000000..a4eb217310 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/resources/helloworldwsjmsclient.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/resources/logging.properties b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/resources/logging.properties new file mode 100644 index 0000000000..3dca310cdb --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-jms/src/test/java/helloworld/HelloWorldJmsClientTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/README b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/README new file mode 100644 index 0000000000..167991c8f7 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/build.xml new file mode 100644 index 0000000000..319353c315 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/helloworld-ws-reference-secure.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/helloworld-ws-reference-secure.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/helloworld-ws-reference-secure.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/helloworld-ws-reference-secure.svg new file mode 100644 index 0000000000..333ad53e0a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/pom.xml new file mode 100644 index 0000000000..ceba605e14 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/pom.xml @@ -0,0 +1,85 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-helloworld-ws-reference-secure + Apache Tuscany SCA Sample HelloWorld Secure Web Service Reference + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.ws.security + wss4j + 1.5.3 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + runtime + + + + org.apache.tuscany.sca + sample-helloworld-ws-service-secure + 1.6.2 + test + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/java/helloworld/ClientPWCBHandler.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldClient.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/definitions.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/definitions.xml new file mode 100644 index 0000000000..0ab3a5a9f1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/helloworldKeys.jks b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/helloworldKeys.jks new file mode 100644 index 0000000000..e2184ad3c6 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/helloworldKeys.jks differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/helloworldwsclient.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/helloworldwsclient.composite new file mode 100644 index 0000000000..904befaf60 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/helloworldwsclient.composite @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/logging.properties b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/logging.properties new file mode 100644 index 0000000000..3a4b43222d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/test/java/helloworld/HelloWorldClientTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference-secure/src/test/java/helloworld/HelloWorldTestServer.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference/README b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/README new file mode 100644 index 0000000000..13c89ab2f6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/build.xml new file mode 100644 index 0000000000..7d5556cd42 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/helloworld-ws-reference.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference/helloworld-ws-reference.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/helloworld-ws-reference.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/helloworld-ws-reference.svg new file mode 100644 index 0000000000..354ffbae8f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/pom.xml new file mode 100644 index 0000000000..78683209ec --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-helloworld-ws-reference + Apache Tuscany SCA Sample HelloWorld Web Service Reference + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + runtime + + + + org.apache.tuscany.sca + sample-helloworld-ws-service + 1.6.2 + test + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldClient.java new file mode 100644 index 0000000000..4559b282fe --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..db0c947cf7 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldServiceComponent.java new file mode 100644 index 0000000000..0dee19550b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite new file mode 100644 index 0000000000..899ad5ce35 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/resources/logging.properties b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/resources/logging.properties new file mode 100644 index 0000000000..3dca310cdb --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..662c9affac --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldClientTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldClientTestCase.java new file mode 100644 index 0000000000..7ce89179c2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldTestServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldTestServer.java new file mode 100644 index 0000000000..8226ec884e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/README b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/README new file mode 100644 index 0000000000..6242253b0c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/README @@ -0,0 +1,97 @@ +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 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 helloworld.wsdl file +and change the location attribute of the element in the +HelloWorldSoapPort definition to use the correct port. + +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/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/build.xml new file mode 100644 index 0000000000..cac3a0857c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/build.xml @@ -0,0 +1,97 @@ + + +]> + + + &buildDependency; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/helloworld-ws-sdo-webapp.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/helloworld-ws-sdo-webapp.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/helloworld-ws-sdo-webapp.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/helloworld-ws-sdo-webapp.svg new file mode 100644 index 0000000000..56a29db23c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/pom.xml new file mode 100644 index 0000000000..2ace06a856 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/pom.xml @@ -0,0 +1,211 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-helloworld-ws-sdo-webapp + war + Apache Tuscany SCA Sample HelloWorld Web Service SDO WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.6.2 + + + + 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 + + + backport-util-concurrent + backport-util-concurrent + + + + + backport-util-concurrent + backport-util-concurrent + 3.1 + + + org.apache.tuscany.sca + tuscany-databinding-sdo + 1.6.2 + compile + + + + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + junit + junit + 4.5 + test + + + + org.codehaus.woodstox + wstx-asl + 3.2.4 + 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.6.2 + + + + true + + + generate + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorld.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorldComponent.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/resources/helloworldws.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/resources/helloworldws.composite new file mode 100644 index 0000000000..34396b1b02 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/resources/helloworldws.composite @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/resources/wsdl/helloworld.xsd b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/webapp/HelloWorld.jsp b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/webapp/HelloWorld.jsp new file mode 100644 index 0000000000..4657c6cdc1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..5b2179a9ba --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..0df1a07467 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,48 @@ + + + + + + + org.apache.tuscany.sca + sample-helloworld-ws-sdo-webapp + 1.6.2 + war + + + + + + org.apache.geronimo.configs + sharedlib + + + + + + org.apache.axiom + org.apache.axis2 + org.apache.commons + org.jdom + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo/README b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/README new file mode 100644 index 0000000000..a322417e61 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/README @@ -0,0 +1,200 @@ +Hello World Web Service and Reference using SDO Sample +====================================================== +This sample demonstrates an SCA service and reference that use 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 includes both a server and a client. First, open a command prompt to start the server. +If you are running ant do the following: + +cd helloworld-ws-sdo +ant run-server + +OR if you don't have ant, on Windows do + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-helloworld-ws-sdo.jar helloworld.HelloWorldServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-sdo.jar helloworld.HelloWorldServer + +You should see the following output: + +Buildfile: build.xml + +run-server: + [java] 30-Sep-2010 14:45:13 org.apache.tuscany.sca.node.impl.NodeImpl + [java] INFO: Creating node: helloworldws.composite + [java] 30-Sep-2010 14:45:13 org.apache.tuscany.sca.node.impl.NodeImpl configureNode + [java] INFO: Loading contribution: file:/E:/td/test161b/samples/helloworld-ws-sdo/target/sample-helloworld-ws-sdo.jar + [java] 30-Sep-2010 14:45:15 org.apache.tuscany.sca.node.impl.NodeImpl start + [java] INFO: Starting node: helloworldws.composite + [java] 30-Sep-2010 14:45:16 org.apache.tuscany.sca.http.jetty.JettyServer addServletMapping + [java] INFO: Added Servlet mapping: http://GrosMorne: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 helloworld.HelloWorldClient + +You should be able to see the following result: + +Buildfile: build.xml + +run: + [java] 30-Sep-2010 14:45:21 org.apache.tuscany.sca.node.impl.NodeImpl + [java] INFO: Creating node: helloworldwsclient.composite + [java] 30-Sep-2010 14:45:21 org.apache.tuscany.sca.node.impl.NodeImpl configureNode + [java] INFO: Loading contribution: file:/E:/td/test161b/samples/helloworld-ws-sdo/target/sample-helloworld-ws-sdo.jar + [java] 30-Sep-2010 14:45:23 org.apache.tuscany.sca.node.impl.NodeImpl start + [java] INFO: Starting node: helloworldwsclient.composite + [java] Injected helloWorldService + [java] Called getGreetings + [java] Hello David Haney + +BUILD SUCCESSFUL +Total time: 9 seconds + + +Sample Overview +--------------- +The sample provides a server component that exposes a service using a web service +binding, and a client component with a reference that invokes the service using a +web service binding. The binding refers to WSDL that describes the service. + +helloworld-ws-sdo/ + src/ + main/ + java/ + helloworld/ + HelloWorldService.java - interface description for + HelloWorldServiceComponent and + HelloWorldImpl + HelloWorldServiceComponent.java - client component implementation + HelloWorldImpl.java - server 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 + 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. + helloworldws.composite - the SCA assembly for the server + helloworldwsclient.composite - the SCA assembly for the client + + test/ + java/ + helloworld/ + HelloWorldClientTestCase.java - JUnit test case + HelloWorldTestServer.java - server launched by the 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. Enter the +following commands: + +cd helloworld-ws-sdo +ant + +To run the sample, you need to run the server and then run the client. +First, run the server. + +cd helloworld-ws-sdo +ant run-server + +In a separate command prompt, run the client. + +cd helloworld-ws-sdo +ant run + +You should see the following output from the run target. + +run: + [java] Injected helloWorldService + [java] Called getGreetings + [java] Hello David Haney + +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 the server in this case since Maven does this for you. +Enter the following commands: + +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/tags/1.6.2-RC1/samples/helloworld-ws-sdo/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/build.xml new file mode 100644 index 0000000000..0cc2b78355 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/build.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + += + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/helloworld-ws-sdo.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo/helloworld-ws-sdo.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/helloworld-ws-sdo.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/helloworld-ws-sdo.svg new file mode 100644 index 0000000000..333ad53e0a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/pom.xml new file mode 100644 index 0000000000..6cdb95b209 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/pom.xml @@ -0,0 +1,165 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-helloworld-ws-sdo + Apache Tuscany SCA Sample HelloWorld Web Service SDO + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + runtime + + + + org.apache.tuscany.sdo + tuscany-sdo-lib + 1.1.1 + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.1.1 + + + backport-util-concurrent + backport-util-concurrent + + + + + backport-util-concurrent + backport-util-concurrent + 3.1 + + + org.apache.tuscany.sca + tuscany-databinding-sdo + 1.6.2 + compile + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.2 + runtime + + + + junit + junit + 4.5 + 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 + + + + generate-helloworld-sdo1 + generate-sources + + ${basedir}/src/main/resources/test.xsd + model.sdo + Entity + true + true + true + + + generate + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldClient.java new file mode 100644 index 0000000000..de4795ceaf --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..c950f7df04 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServer.java new file mode 100644 index 0000000000..e03ed4dc25 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..367c5b4a12 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServiceComponent.java new file mode 100644 index 0000000000..711eef63b5 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BioTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BioTestCase.java new file mode 100644 index 0000000000..39fa5d2d14 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BioTestCase.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.bcircle; + +import model.sdo.EntityFactory; +import model.sdo.Laboratory; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class BioTestCase { + + /** + * @param args + */ + public static void main(String[] args) { + BiochemicalCircle biochemicalCircl = new BiochemicalCircleImpl(); + Laboratory lab2 = biochemicalCircl.getLaboratory("Lab2"); //This invocation without use SCA works ok. + + SCADomain scaDomain = SCADomain.newInstance("resources/clinicalLaboratory.composite"); + BiochemicalCircle biochemicalCircle = + scaDomain.getService(BiochemicalCircle.class, "BiochemicalCircleComponent"); + Laboratory lab = EntityFactory.INSTANCE.createLaboratory(); + lab.setName("lab2"); + biochemicalCircle.setLaboratory(lab); // this invocation works ok too + + lab = biochemicalCircle.getLaboratory("Lab2"); // here I have an exception posted below. + + //here I wait a moment before close scaDomain + System.out.println(lab.getName()); + + scaDomain.close(); + + } +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircle.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircle.java new file mode 100644 index 0000000000..9d77e0cbd9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircle.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.bcircle; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface BiochemicalCircle { + void setLaboratory(model.sdo.Laboratory lab); + + model.sdo.Laboratory getLaboratory(String name); +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircleImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircleImpl.java new file mode 100644 index 0000000000..287e8e22cb --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/java/services/bcircle/BiochemicalCircleImpl.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 services.bcircle; +import model.sdo.EntityFactory; +import model.sdo.Laboratory; + +import org.osoa.sca.annotations.Service; + + +@Service(BiochemicalCircle.class) +public class BiochemicalCircleImpl implements BiochemicalCircle{ + public Laboratory getLaboratory(String name) { + + Laboratory lab = EntityFactory.INSTANCE.createLaboratory(); + lab.setName("Main Laboratory"); + return lab; + } + + public void setLaboratory(Laboratory lab) { + //sad method + System.out.println(lab.getName()); + } +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..1c1216cc17 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/helloworldws.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/helloworldws.composite new file mode 100644 index 0000000000..c255df2897 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/helloworldws.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite new file mode 100644 index 0000000000..d4fba548d5 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/logging.properties b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/logging.properties new file mode 100644 index 0000000000..3dca310cdb --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/resources/clinicalLaboratory.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/resources/clinicalLaboratory.composite new file mode 100644 index 0000000000..32a7e5ddae --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/resources/clinicalLaboratory.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/test.xsd b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/test.xsd new file mode 100644 index 0000000000..7fd9aa0013 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/test.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..2ecc0bea43 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldClientTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldClientTestCase.java new file mode 100644 index 0000000000..11564c370f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldTestServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldTestServer.java new file mode 100644 index 0000000000..4b0c40dafd --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/README b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/README new file mode 100644 index 0000000000..26272b1d91 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/build.xml new file mode 100644 index 0000000000..cc463c2a87 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/helloworld-ws-service.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/helloworld-ws-service.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/helloworld-ws-service.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/helloworld-ws-service.svg new file mode 100644 index 0000000000..8d2ae98c82 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/pom.xml new file mode 100644 index 0000000000..1001744677 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/pom.xml @@ -0,0 +1,92 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-helloworld-ws-service-jms + Apache Tuscany SCA Sample HelloWorld Web Service JMS + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.6.2 + compile + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + compile + + + + org.apache.activemq + activemq-core + 5.2.0 + compile + + + backport-util-concurrent + backport-util-concurrent + 3.1 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldServer.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/resources/definitions.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/resources/definitions.xml new file mode 100644 index 0000000000..f4083f02b8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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:61982 + QueueConnectionFactory + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjms.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjms.composite new file mode 100644 index 0000000000..00fc4e4cb6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjms.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjmspolicy.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjmspolicy.composite new file mode 100644 index 0000000000..10faf374f3 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/resources/helloworldwsjmspolicy.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/test/java/helloworld/HelloWorldJmsPolicyServerTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/test/java/helloworld/HelloWorldJmsPolicyServerTestCase.java new file mode 100644 index 0000000000..c433261b3a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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:61982"); + 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/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/test/java/helloworld/HelloWorldJmsServerTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/test/java/helloworld/HelloWorldJmsServerTestCase.java new file mode 100644 index 0000000000..409b975736 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-jms/src/test/java/helloworld/HelloWorldJmsServerTestCase.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 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.Ignore; +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")); + } + + @Ignore + @Test + public void testWaitForInput() { + System.out.println("Press a key to end"); + try { + System.in.read(); + } catch (Exception ex) { + } + System.out.println("Shutting down"); + } + + @After + public void stopServer() throws Exception { + if (scaDomain != null) { + scaDomain.close(); + } + if (jmsBroker != null) { + jmsBroker.stop(); + } + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/README b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/README new file mode 100644 index 0000000000..f32eb08b05 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/build.xml new file mode 100644 index 0000000000..80aff96f53 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/helloworld-ws-service-secure.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/helloworld-ws-service-secure.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/helloworld-ws-service-secure.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/helloworld-ws-service-secure.svg new file mode 100644 index 0000000000..53eb552923 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/pom.xml new file mode 100644 index 0000000000..3d24e0e348 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/pom.xml @@ -0,0 +1,85 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-helloworld-ws-service-secure + Apache Tuscany SCA Sample HelloWorld Secure Web Service + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.ws.security + wss4j + 1.5.3 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/java/helloworld/HelloWorldServer.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/java/helloworld/ServerPWCBHandler.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/resources/definitions.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/resources/definitions.xml new file mode 100644 index 0000000000..10fa7b8652 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/resources/helloworldKeys.jks b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/resources/helloworldKeys.jks new file mode 100644 index 0000000000..e2184ad3c6 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/resources/helloworldKeys.jks differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/resources/helloworldws.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/resources/helloworldws.composite new file mode 100644 index 0000000000..a078067e9a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/resources/helloworldws.composite @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..32ad8325e9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service-secure/src/test/java/helloworld/HelloWorldServerTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service/README b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/README new file mode 100644 index 0000000000..44dc7ab4e8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/build.xml new file mode 100644 index 0000000000..a20d938748 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/helloworld-ws-service.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service/helloworld-ws-service.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/helloworld-ws-service.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/helloworld-ws-service.svg new file mode 100644 index 0000000000..61cd93ead9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/pom.xml new file mode 100644 index 0000000000..6fffeeb11c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-helloworld-ws-service + Apache Tuscany SCA Sample HelloWorld Web Service + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + compile + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..0de3c70303 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldServer.java new file mode 100644 index 0000000000..c37bfcda65 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..7245513b2a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/resources/META-INF/sca-deployables/helloworldws.composite b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/resources/META-INF/sca-deployables/helloworldws.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..454763410c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/src/test/java/helloworld/HelloWorldServerTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/helloworld-ws-service/src/test/java/helloworld/HelloWorldServerTestCase.java new file mode 100644 index 0000000000..189332be91 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/holder-ws-service/README b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/README new file mode 100644 index 0000000000..8c91a1b92d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/README @@ -0,0 +1,140 @@ +Holder Pattern Service Sample +====================================== +This sample demonstrates an SCA service that uses a web service binding. The +web service binding has been generated from a given WSDL file: + src/main/resources/wsdl/orderservice.wsdl +The generated binding has been placed in src/main/java/org/examle/orderservice +and was generated via the JDK tool wsimport and the command: + wsimport -d orderservice -keep orderservice.wsdl + +The interesting feature of this sample is that the generated service interface, +OrderService, contains a method with the signature: + public void reviewOrder( + @WebParam(name = "myData", targetNamespace = "", mode = WebParam.Mode.INOUT) + javax.xml.ws.Holder orderData); +The orderData parameter is an input/output parameter that is provided by the caller, +updated by the service, and returned to the caller. The business object is updated +in place, a common pattern in web services, and not returned as a response. Tuscany +can handle limited instances of this pattern. + +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-holder-ws-service.jar org.example.orderservice.OrderServiceTestCase + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-holder-ws-service.jar org.example.orderservice.OrderServiceTestCase + +Sample Overview +--------------- +The sample provides a single component that is wired to a service with a +web service binding. + +holder-ws-service/ + src/ + main/ + java/ + org/ + example/ + orderservice + *.java - Web service binding generated from + HelloWorldServiceComponent + resources/ + wsdl/ + orderservice.wsdl - the service description that describes + the exposed service + orderws.composite - the SCA assembly that uses this service + test/ + java/ + helloworld/ + org/ + example/ + orderservice/ + OrderServiceTestCase.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 using the +following commands + +cd holder-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 holder-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 holder-ws-service +mvn + +You should see the following output from the test phase. +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running org.example.orderservice.OrderServiceTestCase +Jan 21, 2009 9:31:11 AM org.apache.tuscany.sca.node.impl.NodeImpl +INFO: Creating node: META-INF/sca-deployables/orderws.composite +Jan 21, 2009 9:31:13 AM org.apache.tuscany.sca.node.impl.NodeImpl configureNode +INFO: Loading contribution: file:/E:/t/branches/sca-java-1.x/samples/holder-ws-webservice/target/classes/ +Jan 21, 2009 9:31:14 AM org.apache.tuscany.sca.node.impl.NodeImpl configureNode +INFO: Loading composite: file:/E:/t/branches/sca-java-1.x/samples/holder-ws-webservice/target/classes/META-INF/sca-deployables/orderws.composite +Jan 21, 2009 9:31:14 AM org.apache.tuscany.sca.node.impl.NodeImpl start +INFO: Starting node: META-INF/sca-deployables/orderws.composite +- No JMS connection factories are defined.Will not listen for any JMS messages +Jan 21, 2009 9:31:15 AM org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.14 +Jan 21, 2009 9:31:15 AM org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +Jan 21, 2009 9:31:15 AM org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8085 +Jan 21, 2009 9:31:15 AM org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8085 +- No JMS connection factories are defined.Will not listen for any JMS messages +Jan 21, 2009 9:31:15 AM org.apache.tuscany.sca.http.tomcat.TomcatServer addServletMapping +INFO: Added Servlet mapping: http://T602010:8085/OrderService +>>> Order submitted=Order[customerId=cust1234,orderId=0,total=50.0,status=Created] +>>> OrderService.reviewOrder return=Order[customerId=cust1234,orderId=0,total=50.0,status=Approved] +>>> Order returned=Order[customerId=cust1234,orderId=0,total=50.0,status=Approved] +Jan 21, 2009 9:31:16 AM org.apache.tuscany.sca.node.impl.NodeImpl stop +INFO: Stopping node: META-INF/sca-deployables/orderws.composite +Jan 21, 2009 9:31:17 AM org.apache.tuscany.sca.http.tomcat.TomcatServer removeServletMapping +INFO: Removed Servlet mapping: http://T602010:8085/OrderService +Jan 21, 2009 9:31:17 AM org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8085 + +Note the console output with ">>>" prefix. This shows that an order was submitted in +the "Created" state, handled by the OrderService reviewOrder method, and returned in +the "Approved" state. This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/build.xml new file mode 100644 index 0000000000..986e1b9cb3 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/pom.xml new file mode 100644 index 0000000000..55a2c7d1c1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-holder-ws-service + Apache Tuscany SCA Holder Input/Output Web Service Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + compile + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/ObjectFactory.java b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/ObjectFactory.java new file mode 100644 index 0000000000..4b5dffbcfa --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/ObjectFactory.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.example.orderservice; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the org.example.orderservice 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: org.example.orderservice + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link ReviewOrderResponse } + * + */ + public ReviewOrderResponse createReviewOrderResponse() { + return new ReviewOrderResponse(); + } + + /** + * Create an instance of {@link Order } + * + */ + public Order createOrder() { + return new Order(); + } + + /** + * Create an instance of {@link ReviewOrder } + * + */ + public ReviewOrder createReviewOrder() { + return new ReviewOrder(); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/Order.java b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/Order.java new file mode 100644 index 0000000000..76caa96d92 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/Order.java @@ -0,0 +1,147 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.example.orderservice; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for order complex type. + * + *

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

+ * <complexType name="order">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="customerId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="status" type="{http://www.example.org/OrderService/}status" minOccurs="0"/>
+ *         <element name="total" type="{http://www.w3.org/2001/XMLSchema}double"/>
+ *         <element name="orderId" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "order", propOrder = { + "customerId", + "status", + "total", + "orderId" +}) +public class Order { + + protected String customerId; + protected Status status; + protected double total; + protected int orderId; + + /** + * Gets the value of the customerId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCustomerId() { + return customerId; + } + + /** + * Sets the value of the customerId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCustomerId(String value) { + this.customerId = value; + } + + /** + * Gets the value of the status property. + * + * @return + * possible object is + * {@link Status } + * + */ + public Status getStatus() { + return status; + } + + /** + * Sets the value of the status property. + * + * @param value + * allowed object is + * {@link Status } + * + */ + public void setStatus(Status value) { + this.status = value; + } + + /** + * Gets the value of the total property. + * + */ + public double getTotal() { + return total; + } + + /** + * Sets the value of the total property. + * + */ + public void setTotal(double value) { + this.total = value; + } + + /** + * Gets the value of the orderId property. + * + */ + public int getOrderId() { + return orderId; + } + + /** + * Sets the value of the orderId property. + * + */ + public void setOrderId(int value) { + this.orderId = value; + } + + // Added manually from wsimport generated class to improve debugging. + public String toString() { + return "Order[customerId=" + customerId + ",orderId=" + orderId + ",total=" + total + ",status=" + status.value() + "]"; + } +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderService.java new file mode 100644 index 0000000000..f0d2b5caa1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderService.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.example.orderservice; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.ws.Holder; +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.1.1 in JDK 6 + * Generated source version: 2.1 + * + */ +@WebService(name = "OrderService", targetNamespace = "http://www.example.org/OrderService/") +@XmlSeeAlso({ + ObjectFactory.class +}) +public interface OrderService { + + + /** + * + * @param myData + */ + @WebMethod(action = "http://www.example.org/OrderService/reviewOrder") + @RequestWrapper(localName = "reviewOrder", targetNamespace = "http://www.example.org/OrderService/", className = "org.example.orderservice.ReviewOrder") + @ResponseWrapper(localName = "reviewOrderResponse", targetNamespace = "http://www.example.org/OrderService/", className = "org.example.orderservice.ReviewOrderResponse") + public void reviewOrder( + @WebParam(name = "myData", targetNamespace = "", mode = WebParam.Mode.INOUT) + Holder myData); + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderServiceImpl.java new file mode 100644 index 0000000000..e4ae074437 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderServiceImpl.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.example.orderservice; + +// import org.osoa.sca.annotations.Service; +import java.util.Random; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.xml.ws.Holder; +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; + +/** + * This class implements the OrderService service. + */ +// @Service(OrderService.class) +public class OrderServiceImpl implements OrderService { + + /** This dummy implementation approves or rejects orders: + * < 100 - always approved. + * 100-1100 - randomly approved. Probability = (1100 - amount)/10 + * >1100 - always rejected. + */ + // public Order reviewOrder(Order order) { + @WebMethod(action = "http://www.example.org/OrderService/reviewOrder") + @RequestWrapper(localName = "reviewOrder", targetNamespace = "http://www.example.org/OrderService/", className = "org.example.orderservice.ReviewOrder") + @ResponseWrapper(localName = "reviewOrderResponse", targetNamespace = "http://www.example.org/OrderService/", className = "org.example.orderservice.ReviewOrderResponse") + public void reviewOrder( + @WebParam(name = "myData", targetNamespace = "", mode = WebParam.Mode.INOUT) + Holder myData) { + Order order = myData.value; + double total = order.getTotal(); + if ( total < 100.0 ) { + order.setStatus( Status.APPROVED ); + } else if ( total > 1100.0 ) { + order.setStatus( Status.REJECTED ); + } else { + int probability = (int) ((-100.0 + total) / 10.0); + Random approver = new Random(); + if ( approver.nextInt( 100 ) < probability ) + order.setStatus( Status.APPROVED ); + else + order.setStatus( Status.REJECTED ); + } + System.out.println( ">>> OrderService.reviewOrder return=" + order ); + // return order; + } +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderServiceServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderServiceServer.java new file mode 100644 index 0000000000..053fbde729 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderServiceServer.java @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.example.orderservice; + +import java.io.IOException; +import javax.xml.ws.Holder; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Tests that the order server responds. + */ +public class OrderServiceServer { + + private SCADomain scaDomain; + + public static void main(String[] args) throws Exception { + OrderServiceServer oss = new OrderServiceServer(); + + oss.startServer(); + oss.testOrderReviewApproved(); + oss.testOrderReviewRejected(); + oss.testOrderReviewRandom(); + oss.stopServer(); + } + + + public void startServer() throws Exception { + scaDomain = SCADomain.newInstance("META-INF/sca-deployables/orderws.composite"); + } + + public void testOrderReviewApproved() throws IOException { + OrderService orderService = + scaDomain.getService(OrderService.class, "OrderServiceComponent/OrderService"); + + Order order = new Order(); + order.setStatus( Status.CREATED ); + order.setCustomerId("cust1234"); + order.setTotal( 50.0 ); + + System.out.println( ">>> Order submitted=" + order ); + Holder holder = new Holder( order ); + orderService.reviewOrder( holder ); + System.out.println( ">>> Order returned=" + holder.value ); + } + + + public void testOrderReviewRejected() throws IOException { + OrderService orderService = + scaDomain.getService(OrderService.class, "OrderServiceComponent/OrderService"); + + Order order = new Order(); + order.setStatus( Status.CREATED ); + order.setCustomerId("cust2345"); + order.setTotal( 50000.0 ); + + System.out.println( ">>> Order submitted=" + order ); + Holder holder = new Holder( order ); + orderService.reviewOrder( holder ); + System.out.println( ">>> Order returned=" + holder.value ); + } + + public void testOrderReviewRandom() throws IOException { + OrderService orderService = + scaDomain.getService(OrderService.class, "OrderServiceComponent/OrderService"); + + Order order = new Order(); + order.setStatus( Status.CREATED ); + order.setCustomerId("cust3456"); + order.setTotal( 600.0 ); + + System.out.println( ">>> Order submitted=" + order ); + Holder holder = new Holder( order ); + orderService.reviewOrder( holder ); + System.out.println( ">>> Order returned=" + holder.value ); + } + + + public void stopServer() throws Exception { + if (scaDomain != null) + scaDomain.close(); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderService_Service.java b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderService_Service.java new file mode 100644 index 0000000000..4a394f2542 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/OrderService_Service.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.example.orderservice; + +import java.net.MalformedURLException; +import java.net.URL; +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.1 in JDK 6 + * Generated source version: 2.1 + * + */ +@WebServiceClient(name = "OrderService", targetNamespace = "http://www.example.org/OrderService/", wsdlLocation = "META-INF/sca-deployables/orderservice.wsdl") +public class OrderService_Service + extends Service +{ + + private final static URL ORDERSERVICE_WSDL_LOCATION; + + static { + URL url = null; + try { + url = new URL("META-INF/sca-deployables/orderservice.wsdl"); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + ORDERSERVICE_WSDL_LOCATION = url; + } + + public OrderService_Service(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + + public OrderService_Service() { + super(ORDERSERVICE_WSDL_LOCATION, new QName("http://www.example.org/OrderService/", "OrderService")); + } + + /** + * + * @return + * returns OrderService + */ + @WebEndpoint(name = "OrderServiceSOAP") + public OrderService getOrderServiceSOAP() { + return (OrderService)super.getPort(new QName("http://www.example.org/OrderService/", "OrderServiceSOAP"), OrderService.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 OrderService + */ + @WebEndpoint(name = "OrderServiceSOAP") + public OrderService getOrderServiceSOAP(WebServiceFeature... features) { + return (OrderService)super.getPort(new QName("http://www.example.org/OrderService/", "OrderServiceSOAP"), OrderService.class, features); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/ReviewOrder.java b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/ReviewOrder.java new file mode 100644 index 0000000000..f4c1add0dd --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/ReviewOrder.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.example.orderservice; + +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="myData" type="{http://www.example.org/OrderService/}order"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "myData" +}) +@XmlRootElement(name = "reviewOrder") +public class ReviewOrder { + + @XmlElement(required = true) + protected Order myData; + + /** + * Gets the value of the myData property. + * + * @return + * possible object is + * {@link Order } + * + */ + public Order getMyData() { + return myData; + } + + /** + * Sets the value of the myData property. + * + * @param value + * allowed object is + * {@link Order } + * + */ + public void setMyData(Order value) { + this.myData = value; + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/ReviewOrderResponse.java b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/ReviewOrderResponse.java new file mode 100644 index 0000000000..4e7187522a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/ReviewOrderResponse.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.example.orderservice; + +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="myData" type="{http://www.example.org/OrderService/}order"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "myData" +}) +@XmlRootElement(name = "reviewOrderResponse") +public class ReviewOrderResponse { + + @XmlElement(required = true) + protected Order myData; + + /** + * Gets the value of the myData property. + * + * @return + * possible object is + * {@link Order } + * + */ + public Order getMyData() { + return myData; + } + + /** + * Sets the value of the myData property. + * + * @param value + * allowed object is + * {@link Order } + * + */ + public void setMyData(Order value) { + this.myData = value; + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/Status.java b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/Status.java new file mode 100644 index 0000000000..4c16ac26e6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/Status.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.example.orderservice; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for status. + * + *

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

+ *

+ * <simpleType name="status">
+ *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
+ *     <enumeration value="Created"/>
+ *     <enumeration value="Submitted"/>
+ *     <enumeration value="Approved"/>
+ *     <enumeration value="Rejected"/>
+ *   </restriction>
+ * </simpleType>
+ * 
+ * + */ +@XmlType(name = "status") +@XmlEnum +public enum Status { + + @XmlEnumValue("Created") + CREATED("Created"), + @XmlEnumValue("Submitted") + SUBMITTED("Submitted"), + @XmlEnumValue("Approved") + APPROVED("Approved"), + @XmlEnumValue("Rejected") + REJECTED("Rejected"); + private final String value; + + Status(String v) { + value = v; + } + + public String value() { + return value; + } + + public static Status fromValue(String v) { + for (Status c: Status.values()) { + if (c.value.equals(v)) { + return c; + } + } + throw new IllegalArgumentException(v); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/package-info.java b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/package-info.java new file mode 100644 index 0000000000..ac03c52974 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/java/org/example/orderservice/package-info.java @@ -0,0 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.example.org/OrderService/") +package org.example.orderservice; diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/resources/META-INF/sca-deployables/orderws.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/resources/META-INF/sca-deployables/orderws.composite new file mode 100644 index 0000000000..d34891d1af --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/resources/META-INF/sca-deployables/orderws.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/resources/wsdl/orderservice.wsdl b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/resources/wsdl/orderservice.wsdl new file mode 100644 index 0000000000..d016994679 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/main/resources/wsdl/orderservice.wsdl @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/test/java/org/example/orderservice/OrderServiceTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/test/java/org/example/orderservice/OrderServiceTestCase.java new file mode 100644 index 0000000000..878e97465e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/holder-ws-service/src/test/java/org/example/orderservice/OrderServiceTestCase.java @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.example.orderservice; + +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertTrue; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +import java.io.IOException; +import javax.xml.ws.Holder; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Tests that the order server responds. + */ +public class OrderServiceTestCase { + + private SCADomain scaDomain; + + @Before + public void startServer() throws Exception { + scaDomain = SCADomain.newInstance("META-INF/sca-deployables/orderws.composite"); + } + + @Test + public void testOrderReviewApproved() throws IOException { + OrderService orderService = + scaDomain.getService(OrderService.class, "OrderServiceComponent/OrderService"); + assertNotNull(orderService); + + Order order = new Order(); + order.setStatus( Status.CREATED ); + order.setCustomerId("cust1234"); + order.setTotal( 50.0 ); + + System.out.println( ">>> Order submitted=" + order ); + Holder holder = new Holder( order ); + orderService.reviewOrder( holder ); + System.out.println( ">>> Order returned=" + holder.value ); + assertTrue( holder.value.getStatus() == Status.APPROVED ); + } + + @Test + public void testOrderReviewRejected() throws IOException { + OrderService orderService = + scaDomain.getService(OrderService.class, "OrderServiceComponent/OrderService"); + assertNotNull(orderService); + + Order order = new Order(); + order.setStatus( Status.CREATED ); + order.setCustomerId("cust2345"); + order.setTotal( 50000.0 ); + + System.out.println( ">>> Order submitted=" + order ); + Holder holder = new Holder( order ); + orderService.reviewOrder( holder ); + System.out.println( ">>> Order returned=" + holder.value ); + assertTrue( holder.value.getStatus() == Status.REJECTED ); + } + + @Test + public void testOrderReviewRandom() throws IOException { + OrderService orderService = + scaDomain.getService(OrderService.class, "OrderServiceComponent/OrderService"); + assertNotNull(orderService); + + Order order = new Order(); + order.setStatus( Status.CREATED ); + order.setCustomerId("cust3456"); + order.setTotal( 600.0 ); + + System.out.println( ">>> Order submitted=" + order ); + Holder holder = new Holder( order ); + orderService.reviewOrder( holder ); + System.out.println( ">>> Order returned=" + holder.value ); + assertTrue( holder.value.getStatus() != Status.CREATED ); + } + + @After + public void stopServer() throws Exception { + if (scaDomain != null) + scaDomain.close(); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/README b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/README new file mode 100644 index 0000000000..27de00e8ef --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-composite/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/build.xml new file mode 100644 index 0000000000..11eecc4d06 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/implementation-composite.png b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/implementation-composite.png new file mode 100644 index 0000000000..4c6d71bc03 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/implementation-composite.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/implementation-composite.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/implementation-composite.svg new file mode 100644 index 0000000000..0e60354aab --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-composite/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/pom.xml new file mode 100644 index 0000000000..947b5ea1e1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/pom.xml @@ -0,0 +1,72 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-implementation-composite + Apache Tuscany SCA Sample Composite Implementation + 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.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/CompositeClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/CompositeClient.java new file mode 100644 index 0000000000..bf743e1797 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/Source.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/Source.java new file mode 100644 index 0000000000..d0efcc1df1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/SourceCallback.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/SourceCallback.java new file mode 100644 index 0000000000..baa95a8e39 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/SourceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/SourceImpl.java new file mode 100644 index 0000000000..72bf552a1e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/SourceImpl.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 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 { + + public static int callbackCount = 0; + 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) { + synchronized(this) { + callbackCount += 1; + } + System.out.println("Work thread " + Thread.currentThread()); + System.out.println("Result: " + result); + } +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/Target.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/Target.java new file mode 100644 index 0000000000..9a8f68a7fa --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/TargetImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/TargetImpl.java new file mode 100644 index 0000000000..e744aa7967 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/java/composite/TargetImpl.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 composite; + +import org.osoa.sca.ComponentContext; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + + +@Service(Target.class) +@Scope("COMPOSITE") +public class TargetImpl implements Target { + + private ComponentContext ctx; + + @Context + public void setContext(ComponentContext context) { + ctx = context; + } + + public void someMethod(String arg) { + System.out.println("Target: " + arg); + SourceCallback sourceCallback = (SourceCallback)ctx.getRequestContext().getCallbackReference().getService(); + sourceCallback.receiveResult(arg + " -> Target.someMethod"); + } +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/resources/InnerComposite.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/resources/InnerComposite.composite new file mode 100644 index 0000000000..3376ac8ff5 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/resources/InnerComposite.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/resources/InnerComposite2.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/resources/InnerComposite2.composite new file mode 100644 index 0000000000..c9eff4fa9d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/resources/InnerComposite2.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/resources/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..5190f402a8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/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/tags/1.6.2-RC1/samples/implementation-composite/src/main/resources/OuterComposite.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/resources/OuterComposite.composite new file mode 100644 index 0000000000..cb1c1e13d4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/main/resources/OuterComposite.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/test/java/composite/CompositeTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/test/java/composite/CompositeTestCase.java new file mode 100644 index 0000000000..980552ac06 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-composite/src/test/java/composite/CompositeTestCase.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 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 { + System.out.println("Main thread " + Thread.currentThread()); + source.clientMethod("Client.main"); + System.out.println("Sleeping ..."); + Thread.sleep(1000); + if (SourceImpl.callbackCount != 2) { + throw new IllegalStateException("Expected callbacks not received"); + } + } +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/README b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/README new file mode 100644 index 0000000000..5e8190648f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/build.xml new file mode 100644 index 0000000000..fcc0615f7e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/build.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/pom.xml new file mode 100644 index 0000000000..c368077f33 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/pom.xml @@ -0,0 +1,77 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-implementation-crud-extension + Apache Tuscany SCA Sample CRUD Implementation Extension + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-assembly + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-interface-java-xml + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-core-spi + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + test + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/CRUD.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/CRUD.java new file mode 100644 index 0000000000..b23d85887b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementation.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementation.java new file mode 100644 index 0000000000..49be844f93 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementationFactory.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementationFactory.java new file mode 100644 index 0000000000..fa83c63c1b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/backend/ResourceManager.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationFactoryImpl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationImpl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationInvoker.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProvider.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProviderFactory.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/resources/META-INF/services/crud.CRUDImplementationFactory b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/resources/sample-implementation-crud.xsd b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/src/main/resources/sample-implementation-crud.xsd @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/test/java/crud/CRUDTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/test/java/crud/CRUDTestCase.java new file mode 100644 index 0000000000..0bb5cfc361 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud-extension/src/test/resources/crud.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/test/resources/crud.composite new file mode 100644 index 0000000000..18745033bb --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud-extension/src/test/resources/crud.composite @@ -0,0 +1,30 @@ + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/README b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/README new file mode 100644 index 0000000000..50da631c04 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/build.xml new file mode 100644 index 0000000000..dbe7992883 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/implementation-crud.png b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/implementation-crud.png new file mode 100644 index 0000000000..a292037e7a Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/implementation-crud.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/implementation-crud.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/implementation-crud.svg new file mode 100644 index 0000000000..dbb37be208 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/implementation-crud.svg @@ -0,0 +1,135 @@ + + + + + + + + + + image/svg+xml + + + + + + + + crud + + CRUDServiceComponent + CRUD + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/pom.xml new file mode 100644 index 0000000000..de7b828d46 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/pom.xml @@ -0,0 +1,64 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-implementation-crud + Apache Tuscany SCA Sample CRUD Implementation Extension Client + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + sample-implementation-crud-extension + 1.6.2 + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/src/main/java/crud/client/CRUDClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/src/main/java/crud/client/CRUDClient.java new file mode 100644 index 0000000000..ea87cb3001 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-crud/src/main/resources/crud.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/src/main/resources/crud.composite new file mode 100644 index 0000000000..18745033bb --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/src/main/resources/crud.composite @@ -0,0 +1,30 @@ + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/src/test/java/crud/client/CRUDTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-crud/src/test/java/crud/client/CRUDTestCase.java new file mode 100644 index 0000000000..7e0476a8b1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-notification/README b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/README new file mode 100644 index 0000000000..7adfa4e5dc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/README @@ -0,0 +1,97 @@ +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, use following command: + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-implementation-notification.jar notification.TrafficAdvisoryClient + +on *nix, use following command: + +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/tags/1.6.2-RC1/samples/implementation-notification/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/build.xml new file mode 100644 index 0000000000..536114f4bc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/implementation-notification.png b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/implementation-notification.png new file mode 100644 index 0000000000..0b7ee34bf7 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/implementation-notification.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/pom.xml new file mode 100644 index 0000000000..c93cb2cfa7 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/pom.xml @@ -0,0 +1,76 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-implementation-notification + Apache Tuscany SCA Sample Notification Implementation + 1.6.2 + A sample illustrating use of implementation.notification + + + + org.apache.tuscany.sca + tuscany-implementation-notification + 1.6.2 + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + test + + + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + install + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/java/notification/TestCaseProducer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/java/notification/TestCaseProducer.java new file mode 100644 index 0000000000..bf8c72e0ce --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-notification/src/main/java/notification/TrafficAdvisory.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/java/notification/TrafficAdvisory.java new file mode 100644 index 0000000000..7bbfda2122 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryClient.java new file mode 100644 index 0000000000..da32bab58d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryConsumer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryConsumer.java new file mode 100644 index 0000000000..2aaae596be --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryProducer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryProducer.java new file mode 100644 index 0000000000..a0bb02e846 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.componentType b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.componentType new file mode 100644 index 0000000000..873e200613 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.componentType @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.composite new file mode 100644 index 0000000000..bbf2281352 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/main/resources/TrafficAdvisoryNotification.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + Consumer1 + + + + + Consumer2 + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/test/java/notification/TrafficAdvisoryTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/test/java/notification/TrafficAdvisoryTestCase.java new file mode 100644 index 0000000000..719141c94b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType new file mode 100644 index 0000000000..873e200613 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite new file mode 100644 index 0000000000..bbf2281352 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + Consumer1 + + + + + Consumer2 + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/README b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/README new file mode 100644 index 0000000000..9c11fa08ea --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/README @@ -0,0 +1,104 @@ +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. + +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-pojo-extension.jar;target\test-classes helloworld.HelloWorldTestClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-implementation-pojo-extension.jar:target/test-classes helloworld.HelloWorldTestClient + +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-pojo-extension.jar - the new POJO implementation + extension +target.test-classes - application code that uses the + POJO implementation + +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 + HelloWorldTestClient.java - Test client with no JUnit dependency + 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 and run +using Ant as follows + +cd implementation-pojo-extension +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] Initializing POJO + [java] Initializing POJO + [java] Executing POJO sayHello + [java] Executing POJO sayHello + [java] Destroying POJO + [java] Destroying POJO + +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/tags/1.6.2-RC1/samples/implementation-pojo-extension/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/build.xml new file mode 100644 index 0000000000..122647748d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/pom.xml new file mode 100644 index 0000000000..3f4d830e3d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/pom.xml @@ -0,0 +1,99 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-implementation-pojo-extension + Apache Tuscany SCA Sample POJO Implementation Extension + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-interface-java-xml + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-core-spi + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + test + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + org.apache.maven.plugins + maven-assembly-plugin + + + test + package + + single + + + + src/test/assembly/test.xml + + gnu + ${artifactId} + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java new file mode 100644 index 0000000000..7c2f5d236f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java new file mode 100644 index 0000000000..bbcfb3d0dc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java new file mode 100644 index 0000000000..36bce82e09 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java @@ -0,0 +1,173 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package 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 + 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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/resources/sample-implementation-pojo.xsd b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/main/resources/sample-implementation-pojo.xsd @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/assembly/test.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/assembly/test.xml new file mode 100644 index 0000000000..ece2cbc08c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/assembly/test.xml @@ -0,0 +1,34 @@ + + + + test + false + + jar + + + + + target/test-classes + / + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java new file mode 100644 index 0000000000..cc32929f09 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..0580e30aba --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java new file mode 100644 index 0000000000..69ab1f567e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java new file mode 100644 index 0000000000..d8b5f41adc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestClient.java new file mode 100644 index 0000000000..c157dadb66 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestClient.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; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Tests the POJO implementation extension. + */ +public class HelloWorldTestClient { + + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("helloworld/helloworld.composite"); + + HelloWorld helloworld = scaDomain.getService(HelloWorld.class, "HelloWorldComponent"); + assert "Hello petra".equals(helloworld.sayHello("petra")); + + helloworld = scaDomain.getService(HelloWorld.class, "HelloWorldComponent2/HelloWorld2"); + assert "Hello petra".equals(helloworld.sayHello("petra")); + + scaDomain.close(); + } +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType new file mode 100644 index 0000000000..a92c5ab8db --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite new file mode 100644 index 0000000000..c38094dfc9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/README b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/README new file mode 100644 index 0000000000..11fecf2ae8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/build-bundles.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/build-bundles.xml new file mode 100644 index 0000000000..7a31e6016b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/build-bundles.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/build.xml new file mode 100644 index 0000000000..2de08e74a3 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/build.xml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/osgi-supplychain.png b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/osgi-supplychain.png new file mode 100644 index 0000000000..2bec57ac8a Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/osgi-supplychain.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/osgi-supplychain.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/osgi-supplychain.svg new file mode 100644 index 0000000000..43cb427944 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/pom.xml new file mode 100644 index 0000000000..f452a3876b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/pom.xml @@ -0,0 +1,187 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-osgi-supplychain + Apache Tuscany SCA Sample OSGi Supply Chain + + + + + org.apache.felix + org.apache.felix.main + 1.0.4 + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-osgi + 1.6.2 + runtime + + + + junit + junit + 4.5 + 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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/OSGiBundleImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/OSGiBundleImpl.java new file mode 100644 index 0000000000..5f40054ada --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/SupplyChainClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/SupplyChainClient.java new file mode 100644 index 0000000000..64814487cb --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/customer/Customer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/customer/Customer.java new file mode 100644 index 0000000000..225dce0236 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java new file mode 100644 index 0000000000..023d716651 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java new file mode 100644 index 0000000000..a1c7fce60a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerImpl.java new file mode 100644 index 0000000000..4647a716c7 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.java new file mode 100644 index 0000000000..d0d29f94f8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.java new file mode 100644 index 0000000000..1b7fb15bf1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerImpl.java new file mode 100644 index 0000000000..e97331c06c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/retailer/Retailer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/retailer/Retailer.java new file mode 100644 index 0000000000..1e87d59af1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/shipper/JavaShipperComponentImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/shipper/JavaShipperComponentImpl.java new file mode 100644 index 0000000000..4206ce7dc8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperComponentImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperComponentImpl.java new file mode 100644 index 0000000000..0f88cca213 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperImpl.java new file mode 100644 index 0000000000..f55a068ede --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/shipper/Shipper.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/shipper/Shipper.java new file mode 100644 index 0000000000..2514928c10 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/warehouse/JavaWarehouseComponentImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/warehouse/JavaWarehouseComponentImpl.java new file mode 100644 index 0000000000..72eec76cc2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseComponentImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseComponentImpl.java new file mode 100644 index 0000000000..600f3f0c74 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseImpl.java new file mode 100644 index 0000000000..b8bca97bd0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/warehouse/Warehouse.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/java/supplychain/warehouse/Warehouse.java new file mode 100644 index 0000000000..6f1f6b8730 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/Customer.componentType b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/Customer.componentType new file mode 100644 index 0000000000..5c61a0961c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSCustomer.componentType b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSCustomer.componentType new file mode 100644 index 0000000000..87a184d968 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSCustomer.componentType @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSRetailer.componentType b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSRetailer.componentType new file mode 100644 index 0000000000..872ab6601a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSRetailer.componentType @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSShipper.componentType b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSShipper.componentType new file mode 100644 index 0000000000..57fcbbc5d1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSShipper.componentType @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSWarehouse.componentType b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSWarehouse.componentType new file mode 100644 index 0000000000..75fa8029f7 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/DSWarehouse.componentType @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/Retailer.componentType b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/Retailer.componentType new file mode 100644 index 0000000000..15185f2bf9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/Shipper.componentType b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/Shipper.componentType new file mode 100644 index 0000000000..675597d80b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/Warehouse.componentType b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/Warehouse.componentType new file mode 100644 index 0000000000..6e1ac3e5a9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/Customer.mf b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/Customer.mf new file mode 100644 index 0000000000..88d79e5219 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/Retailer.mf b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/Retailer.mf new file mode 100644 index 0000000000..d95ef5d582 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/Shipper.mf b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/Shipper.mf new file mode 100644 index 0000000000..de7ac7ec7a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/Warehouse.mf b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/Warehouse.mf new file mode 100644 index 0000000000..21241a6899 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.mf b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.mf new file mode 100644 index 0000000000..b5c5a862be --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.xml new file mode 100644 index 0000000000..5b368afd5b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.xml @@ -0,0 +1,32 @@ + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.mf b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.mf new file mode 100644 index 0000000000..47897d16ca --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.xml new file mode 100644 index 0000000000..cae7fdfde2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.xml @@ -0,0 +1,32 @@ + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.mf b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.mf new file mode 100644 index 0000000000..f5333c7caa --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.xml new file mode 100644 index 0000000000..d894309b71 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.xml @@ -0,0 +1,33 @@ + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.mf b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.mf new file mode 100644 index 0000000000..6166549e5a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.xml new file mode 100644 index 0000000000..fc86a76784 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.xml @@ -0,0 +1,32 @@ + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/supplychain.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/supplychain.composite new file mode 100644 index 0000000000..0bbfed9176 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/supplychain.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/supplychain.ds.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/supplychain.ds.composite new file mode 100644 index 0000000000..d1e11168e2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/main/resources/supplychain.ds.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/osgi-supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java new file mode 100644 index 0000000000..ff15c0d9a2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/README b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/README new file mode 100644 index 0000000000..8c8abb8881 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/README @@ -0,0 +1,30 @@ +Photo-Gallery Sample +====================================== + +This is a sample picture gallery application using Tuscany SCA. + +Running And Building The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be run using Ant as follows: + +cd photo-gallery +ant run + +Once the application is running use your browser to visit the following +URL: + +http://localhost:8080/gallery/ + +If you want to build it before running it, you can do: + +cd photo-gallery +ant compile +ant run + +Building The Sample Using Maven +------------------------------- +With the source and binary distributions the sample can be built using Maven +as follows: + +cd photo-gallery +mvn diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/build.xml new file mode 100644 index 0000000000..5b487ba5a2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/build.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/photo-gallery.png b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/photo-gallery.png new file mode 100644 index 0000000000..0e0ae8b9ec Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/photo-gallery.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/photo-gallery.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/photo-gallery.svg new file mode 100644 index 0000000000..9136fef9ad --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/photo-gallery.svg @@ -0,0 +1,226 @@ + + + + + + + + + + image/svg+xml + + + + + + + + photo-gallery + gallery + + + + + + + HTTP JSONRPC + + + Album + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/pom.xml new file mode 100644 index 0000000000..7a5916597e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/pom.xml @@ -0,0 +1,127 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../pom.xml + + sample-photo-gallery + Apache Tuscany SCA Sample Photo Gallery + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-data-api + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-widget-runtime-tuscany + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-js + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-js + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.6.2 + runtime + + + + org.apache.derby + derby + + 10.3.1.4 + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/java/launch/LaunchGallery.java b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/java/launch/LaunchGallery.java new file mode 100644 index 0000000000..1007cd49b0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/java/services/Album.java b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/java/services/Album.java new file mode 100644 index 0000000000..5257d0e703 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/java/services/AlbumImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/java/services/AlbumImpl.java new file mode 100644 index 0000000000..dd2b086e29 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery.html b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery.html new file mode 100644 index 0000000000..864987df12 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00368.jpg b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00368.jpg differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00369.jpg b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00369.jpg differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00370.jpg b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00370.jpg differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00371.jpg b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00371.jpg differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00373.jpg b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00373.jpg differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00375.jpg b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00375.jpg differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00376.jpg b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00376.jpg differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00377.jpg b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00377.jpg differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00378.jpg b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00378.jpg differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00379.jpg b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00379.jpg differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00380.jpg b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/gallery/boston/dsc00380.jpg differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/index.gif b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/index.gif differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/index_on.gif b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/index_on.gif differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/next.gif b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/next.gif differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/next_disabled.gif b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/next_disabled.gif differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/next_on.gif b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/next_on.gif differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/photo-gallery.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/photo-gallery.composite new file mode 100644 index 0000000000..0bb3c4b4db --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/photo-gallery.composite @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + gallery + boston + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/prev.gif b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/prev.gif differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/prev_disabled.gif b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/prev_disabled.gif differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/prev_on.gif b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/prev_on.gif differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/show_slide.gif b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/show_slide.gif differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/space.gif b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/space.gif differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/styles.css b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/styles.css new file mode 100755 index 0000000000..f432889821 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/photo-gallery/src/main/resources/styles.css @@ -0,0 +1,139 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +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/tags/1.6.2-RC1/samples/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/pom.xml new file mode 100644 index 0000000000..ea0dcfad7b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/pom.xml @@ -0,0 +1,110 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../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-corba-reference + calculator-corba-service + calculator-distributed + calculator-implementation-policies + calculator-rmi-reference + calculator-rmi-service + calculator-script + calculator-webapp + calculator-ws-webapp + callback-ws-client + callback-ws-service + callbacks-jms + chat-webapp + databinding-echo + domain-management + feed-aggregator + feed-aggregator-webapp + helloworld-bpel + helloworld-dojo-webapp + helloworld-erlang-reference + helloworld-erlang-service + 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-jms + helloworld-ws-reference-secure + helloworld-ws-sdo + helloworld-ws-sdo-webapp + holder-ws-service + implementation-composite + implementation-crud + implementation-crud-extension + implementation-notification + implementation-pojo-extension + 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-dojo + store-webapp + store-secure + supplychain + web-resource + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/README b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/README new file mode 100644 index 0000000000..b92e8671e6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/README @@ -0,0 +1,358 @@ +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 run-server + +Command Prompt 2: +ant run + +OR if you don't have ant, on Windows do + +Command Prompt 1: +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-quote-xquery.jar xquery.quote.XQueryQuoteServer +Command Prompt 2: +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-quote-xquery.jar xquery.quote.XQueryQuoteClient + +and on *nix do + +Command Prompt 1: +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-quote-xquery.jar xquery.quote.XQueryQuoteServer +Command Prompt 2: +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 service side: +Buildfile: build.xml + +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 +----------------------------------------- +With the binary distribution the sample can be built and run using Maven +as follows: + +cd quote-xquery +ant compile +ant run-server + +(then from another command prompt) +cd quote-xquery +ant run + + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distribution 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/tags/1.6.2-RC1/samples/quote-xquery/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/build.xml new file mode 100644 index 0000000000..2e7ffb9c8a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/build.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/pom.xml new file mode 100644 index 0000000000..67511165b2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/pom.xml @@ -0,0 +1,195 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-quote-xquery + Apache Tuscany SCA Sample XQuery Quote Implementation + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-xquery + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + runtime + + + + org.apache.tuscany.sdo + tuscany-sdo-lib + 1.1.1 + + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.1.1 + + + backport-util-concurrent + backport-util-concurrent + + + + + backport-util-concurrent + backport-util-concurrent + 3.1 + + + + + + net.sf.saxon + saxon + 8.7 + + + + org.apache.tuscany.sca + tuscany-databinding-sdo + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.6.2 + runtime + + + + junit + junit + 4.5 + 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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderImpl.java new file mode 100644 index 0000000000..8a42136b5d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderNodeInfo.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderNodeInfo.java new file mode 100644 index 0000000000..41d78683cc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderService.java new file mode 100644 index 0000000000..f744a59744 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/ExternalReferencesQuoteJoin.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/ExternalReferencesQuoteJoin.java new file mode 100644 index 0000000000..374c0825e9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProvider.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProvider.java new file mode 100644 index 0000000000..fbe38b8269 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderImpl.java new file mode 100644 index 0000000000..d2d175430b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderNodeInfo.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderNodeInfo.java new file mode 100644 index 0000000000..06c3945a6e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/PropertiesQuoteJoin.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/PropertiesQuoteJoin.java new file mode 100644 index 0000000000..1ecdf120c2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculator.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculator.java new file mode 100644 index 0000000000..85508eaa46 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculatorImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculatorImpl.java new file mode 100644 index 0000000000..26331381a8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteDataUtil.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteDataUtil.java new file mode 100644 index 0000000000..8ed02dc1ef --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoin.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoin.java new file mode 100644 index 0000000000..425867055b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocal.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocal.java new file mode 100644 index 0000000000..cfd201f883 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocalImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocalImpl.java new file mode 100644 index 0000000000..20fe73fd92 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteClient.java new file mode 100644 index 0000000000..adc852acd4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/java/xquery/quote/XQueryQuoteServer.java new file mode 100644 index 0000000000..3fa3cdb637 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_external_references.xq b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_properties.xq b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/AvailQuote.xsd b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/AvailQuote.xsd new file mode 100644 index 0000000000..e7f3e67068 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/AvailQuote.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/PriceQuote.xsd b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/PriceQuote.xsd new file mode 100644 index 0000000000..4c437586ef --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/PriceQuote.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/Quote.xsd b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/Quote.xsd new file mode 100644 index 0000000000..4f64850056 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/Quote.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl new file mode 100644 index 0000000000..96c2af138a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/xqueryquotews.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/xqueryquotews.composite new file mode 100644 index 0000000000..9e35e2ecb2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/xqueryquotews.composite @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite new file mode 100644 index 0000000000..c9887c8c19 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + 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/tags/1.6.2-RC1/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteClientTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteClientTestCase.java new file mode 100644 index 0000000000..9555532b3e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteTestServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteTestServer.java new file mode 100644 index 0000000000..9a4be5bda6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/README b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/README new file mode 100644 index 0000000000..407ed753ab --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/README @@ -0,0 +1,180 @@ +Spring Bigbank Sample +===================== +This sample is different from the simple-bigbank sample in that it is made of 4 separate modules that represent the different aspects of a fictitious banking application. + +simple-bigbank-spring (this module) +spring-bigbank-calculator +spring-bigbank-checkaccount +spring-bigbank-stockquote + +To run the simple-bigbank-spring sample you need to first run the spring-bigbank-calculator, spring-bigbank-checkaccount and +spring-bigbank-stockquote samples. This will start the three applications on separate copies of the Tuscany runtime and make +the applications available as services. The simple-bigbank-spring sample is dependent on these services. + +Start spring-bigbank-calculator sample +-------------------------------------- + +The spring-bigbank-calculator sample runs the Calculator composite 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 Calculator composite and make it available as an RMI service for this sample do the following: + +cd spring-bigbank-calculator +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-spring-bigbank-calculator.jar bigbank.calculator.server.CalculatorServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-spring-bigbank-calculator.jar bigbank.calculator.server.CalculatorServer + +.. Leave the server running + +Start spring-bigbank-checkaccount sample +---------------------------------------- + +This contains all artifacts that deal with the account management within the bigbank. The JMS service offered by the spring-bigbank-checkaccount sample +is used by the simple-bigbank-spring sample. + +cd spring-bigbank-checkaccount +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-spring-bigbank-checkaccount.jar bigbank.account.checking.server.CheckingAccountServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-spring-bigbank-checkaccount.jar bigbank.account.checking.server.CheckingAccountServer + +.. Leave the server running + +Start spring-bigbank-stockquote sample +-------------------------------------- + +This is 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 depending on the availability of a web service. + +cd spring-bigbank-stockquote +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-spring-bigbank-stockquote.jar bigbank.stockquote.server.StockQuoteServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-spring-bigbank-stockquote.jar bigbank.stockquote.server.StockQuoteServer + +.. Leave the server running + +Start simple-bigbank-spring sample +---------------------------------- + +This contains all artifacts that make up the bigbank application. This is the application that the end user interacts with. + +Start simple-bigbank-spring in the following way: + +cd simple-bigbank-spring +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-simple-bigbank-spring.jar bigbank.client.BigBankClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-simple-bigbank-spring.jar bigbank.client.BigBankClient + + +Sample Overview +--------------- +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 results 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 spring-bigbank-calculator +ant compile +ant run + +cd spring-bigbank-checkaccount +ant compile +ant run + +cd spring-bigbank-stockquote +ant compile +ant run + +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] Checking account: CHA_Customer_01, balance:1000.0 + [java] Savings account: SVA_Customer_01, balance:1000.0 + [java] Stock account: STA_Customer_01, symbol:IBM, quantity:100 + [java] Stock price for IBM: 104.64 + [java] Converted to EURO: 73.24799999999999 + [java] Account summary: currency: EURO, [CHA_Customer_01, balance:1000.0, S +VA_Customer_01, balance:1000.0, STA_Customer_01, symbol:IBM, quantity:100, STA_C +ustomer_01, symbol:IBM, quantity:100] + + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. + +cd simple-bigbank-spring +mvn + +You should see the following output from the test phase. +** Please note that balance amount will vary depending on the random stock value. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running bigbank.BigBankTestCase +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/tags/1.6.2-RC1/samples/simple-bigbank-spring/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/build.xml new file mode 100644 index 0000000000..7efd47d409 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/pom.xml new file mode 100644 index 0000000000..35b8fcd405 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/pom.xml @@ -0,0 +1,229 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-simple-bigbank-spring + Apache Tuscany SCA Sample Spring Based Simplified BigBank + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-core-spi + 1.6.2 + + + + org.apache.ws.security + wss4j + 1.5.3 + + + + commons-httpclient + commons-httpclient + 3.1 + + + + commons-logging + commons-logging + 1.1 + + + javax.servlet + servlet-api + + + + + + org.apache.tuscany.sca + tuscany-data-api + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-spring + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-spring-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-rmi-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-rss-rome + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-resource-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + sample-spring-bigbank-checkaccount + 1.6.2 + test + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.2 + runtime + + + + org.springframework + spring-core + 2.5.5 + + + + org.springframework + spring-beans + 2.5.5 + + + + org.springframework + spring-context + 2.5.5 + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/simple-bigbank-spring.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/simple-bigbank-spring.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/simple-bigbank-spring.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/simple-bigbank-spring.svg new file mode 100644 index 0000000000..c64f6de6b9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountReport.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountServiceImpl.java new file mode 100644 index 0000000000..be02087c7d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountServiceImpl.java @@ -0,0 +1,147 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account; + +import java.util.ArrayList; +import java.util.List; + +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 + */ +public class AccountServiceImpl implements AccountService { + + private SavingsAccountService savingsAccountService; + + private CheckingAccountService checkingAccountService; + + private StockAccountService stockAccountService; + + private CalculatorService calculatorService; + + private StockQuoteService stockQuoteService; + + private String currency; + + public AccountServiceImpl(SavingsAccountService savingsAccountService, StockAccountService stockAccountService) { + this.savingsAccountService = savingsAccountService; + this.stockAccountService = stockAccountService; + } + + 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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountDetails.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/checking/CheckingAccountService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/feed/AccountFeedImpl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountDetails.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountDetails.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/calculator/CalculatorService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/server/BigBankServer.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/java/bigbank/stockquote/StockQuoteService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/BigBank.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/BigBank.composite new file mode 100644 index 0000000000..ea2dbc7e1c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/BigBank.composite @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/SavingsAccount.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/SavingsAccount.composite new file mode 100644 index 0000000000..4bb2ce61ef --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/SavingsAccount.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/StockAccount.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/StockAccount.composite new file mode 100644 index 0000000000..97dff499ba --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/StockAccount.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/spring-context/Account-spring-context.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/spring-context/Account-spring-context.xml new file mode 100644 index 0000000000..08bc82b8ff --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/spring-context/Account-spring-context.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/spring-context/SavingsAccount-context.xml b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/spring-context/SavingsAccount-context.xml @@ -0,0 +1,33 @@ + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/spring-context/StockAccount/META-INF/MANIFEST.MF b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/spring-context/StockAccount/META-INF/spring/StockAccount-context.xml b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/web/style.css b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/main/resources/web/style.css new file mode 100644 index 0000000000..1071583264 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/test/java/bigbank/BigBankTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank-spring/src/test/java/bigbank/BigBankTestCase.java new file mode 100644 index 0000000000..d82e383e46 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank/README b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/README new file mode 100644 index 0000000000..d59043d833 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/README @@ -0,0 +1,101 @@ +Simple BigBank Sample +================= +This sample implements a simple a version of the BigBank scenario 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. + +simple-bigbank/ + 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/tags/1.6.2-RC1/samples/simple-bigbank/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/build.xml new file mode 100644 index 0000000000..823fe74168 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/pom.xml new file mode 100644 index 0000000000..4b8aea2a36 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-simple-bigbank + Apache Tuscany SCA Sample Simplified BigBank + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/simple-bigbank.png b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/simple-bigbank.png new file mode 100644 index 0000000000..593c047f6a Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/simple-bigbank.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/simple-bigbank.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/simple-bigbank.svg new file mode 100644 index 0000000000..c64f6de6b9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/account/AccountReport.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/account/AccountReport.java new file mode 100644 index 0000000000..1625ff5b65 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/account/AccountService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/account/AccountService.java new file mode 100644 index 0000000000..7c9082b944 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/account/AccountServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/account/AccountServiceImpl.java new file mode 100644 index 0000000000..fa85f309c0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/Account.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/Account.java new file mode 100644 index 0000000000..a5ae7b3955 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataService.java new file mode 100644 index 0000000000..c354de387b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataServiceImpl.java new file mode 100644 index 0000000000..000acb935c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/CheckingAccount.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/CheckingAccount.java new file mode 100644 index 0000000000..11bdff757e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/SavingsAccount.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/SavingsAccount.java new file mode 100644 index 0000000000..b791024076 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/StockAccount.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/accountdata/StockAccount.java new file mode 100644 index 0000000000..86246a3f84 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/client/BigBankClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/client/BigBankClient.java new file mode 100644 index 0000000000..edbf910d37 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java new file mode 100644 index 0000000000..0512d40b0b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java new file mode 100644 index 0000000000..7961279352 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-bigbank/src/main/resources/Account.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/resources/Account.composite new file mode 100644 index 0000000000..e71615e27e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/resources/Account.composite @@ -0,0 +1,38 @@ + + + + + + + + + + USD + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/resources/BigBank.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/resources/BigBank.composite new file mode 100644 index 0000000000..c870f39cab --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/resources/BigBank.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/resources/StockQuote.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/resources/StockQuote.composite new file mode 100644 index 0000000000..4f29c14851 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/main/resources/StockQuote.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/test/java/bigbank/BigBankTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-bigbank/src/test/java/bigbank/BigBankTestCase.java new file mode 100644 index 0000000000..ba6c1dd797 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback-ws/README b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/README new file mode 100644 index 0000000000..6b27718f74 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback-ws/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/build.xml new file mode 100644 index 0000000000..83173f56a5 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/pom.xml new file mode 100644 index 0000000000..8154b7c97e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-simple-callback-ws + Apache Tuscany SCA Sample Simple Callback WebService + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/simple-callback-ws.png b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback-ws/simple-callback-ws.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/simple-callback-ws.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/simple-callback-ws.svg new file mode 100644 index 0000000000..7d9e3de510 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/MyClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/MyClient.java new file mode 100644 index 0000000000..4cc00d6d0f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/MyClientImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/MyClientImpl.java new file mode 100644 index 0000000000..ad7c6d8fef --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/MyService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/MyService.java new file mode 100644 index 0000000000..48acc0e94f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceCallback.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceCallback.java new file mode 100644 index 0000000000..66cfb2bc8a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceImpl.java new file mode 100644 index 0000000000..08057d2fcc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/SimpleCallbackClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/java/simplecallback/SimpleCallbackClient.java new file mode 100644 index 0000000000..eeb0e52163 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/resources/simplecallback.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/resources/simplecallback.composite new file mode 100644 index 0000000000..53e7fe66af --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/resources/simplecallback.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl new file mode 100644 index 0000000000..8a6465de3a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/test/java/simplecallback/SimpleCallbackTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback-ws/src/test/java/simplecallback/SimpleCallbackTestCase.java new file mode 100644 index 0000000000..580a7f6b0c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback/README b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/README new file mode 100644 index 0000000000..719376f254 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/build.xml new file mode 100644 index 0000000000..ccfb5cd63f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/pom.xml new file mode 100644 index 0000000000..9e5be1493b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-simple-callback + Apache Tuscany SCA Sample Simple Callback + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/simple-callback.png b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/simple-callback.png new file mode 100644 index 0000000000..1b6353f5cf Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/simple-callback.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/simple-callback.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/simple-callback.svg new file mode 100644 index 0000000000..484b65df9d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/simple-callback.svg @@ -0,0 +1,150 @@ + + + + + + + + + + image/svg+xml + + + + + + + + simplecallback + MyServiceComponent + + + MyClientComponent + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/MyClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/MyClient.java new file mode 100644 index 0000000000..4cc00d6d0f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/MyClientImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/MyClientImpl.java new file mode 100644 index 0000000000..3e2a1df5a5 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/MyService.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/MyService.java new file mode 100644 index 0000000000..e78ad6f68f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/MyServiceCallback.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/MyServiceCallback.java new file mode 100644 index 0000000000..b27eea44f5 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/MyServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/MyServiceImpl.java new file mode 100644 index 0000000000..fc5e31d14e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/SimpleCallbackClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/java/simplecallback/SimpleCallbackClient.java new file mode 100644 index 0000000000..b8987fcd07 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/simple-callback/src/main/resources/simplecallback.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/resources/simplecallback.composite new file mode 100644 index 0000000000..33e6f60601 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/main/resources/simplecallback.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/test/java/simplecallback/SimpleCallbackTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/simple-callback/src/test/java/simplecallback/SimpleCallbackTestCase.java new file mode 100644 index 0000000000..cbaab8af83 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-calculator/README b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/README new file mode 100644 index 0000000000..cfa88c6c53 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/README @@ -0,0 +1,2 @@ +The spring-bigbank-calculator module is part of the simple-bigbank-spring sample. +Please see the README file under simple-bigbank-spring to understand how spring-bigbank-calculator fits into the overall picture. diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/build.xml new file mode 100644 index 0000000000..92eb9cc417 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/pom.xml new file mode 100644 index 0000000000..93dc485dd2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/pom.xml @@ -0,0 +1,117 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-spring-bigbank-calculator + Apache Tuscany SCA Sample Spring-Based BigBank Calculator + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-script + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-spring + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-spring-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-rmi-runtime + 1.6.2 + runtime + + + + org.springframework + spring-core + 2.5.5 + + + + org.springframework + spring-beans + 2.5.5 + + + + org.springframework + spring-context + 2.5.5 + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/AddService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/CalculatorService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/CalculatorServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/DivideService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/MultiplyService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/SubtractService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/server/CalculatorServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/server/CalculatorServer.java new file mode 100644 index 0000000000..be51896660 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/java/bigbank/calculator/server/CalculatorServer.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 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 { + long timeout = -1L; + if (args.length > 0) { + timeout = Long.parseLong(args[0]); + } + + System.out.println("Starting the Sample SCA Calculator..."); + + SCANodeFactory factory = SCANodeFactory.newInstance(); + SCANode node = factory.createSCANodeFromClassLoader("Calculator.composite", CalculatorServer.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"); + + // The following line is a workaround for TUSCANY-3277 (the JVM hangs when exiting). + System.exit(0); + } + +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/Calculator.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..504a4ccfcd --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/Calculator.composite @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/META-INF/spring/CalculatorService-context.xml b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/META-INF/spring/CalculatorService-context.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/calculator/AddServiceImpl.js b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/calculator/AddServiceImpl.js new file mode 100644 index 0000000000..6f11106ddd --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/calculator/DivideServiceImpl.groovy b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/calculator/DivideServiceImpl.groovy new file mode 100644 index 0000000000..c31c1e8fd6 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/calculator/MultiplyServiceImpl.py b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/calculator/MultiplyServiceImpl.py new file mode 100644 index 0000000000..cfd96f287a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/calculator/SubtractServiceImpl.rb b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/main/resources/calculator/SubtractServiceImpl.rb new file mode 100644 index 0000000000..8e7a884d41 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/test/java/bigbank/calculator/CalculatorServiceTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/test/java/bigbank/calculator/CalculatorServiceTestCase.java new file mode 100644 index 0000000000..02a11485cd --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-calculator/src/test/java/bigbank/calculator/CalculatorServiceTestCase.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.calculator; + +import junit.framework.TestCase; +import bigbank.calculator.server.CalculatorServer; + +/** + * Tests out the big bank service + * + */ +public class CalculatorServiceTestCase extends TestCase { + + public void testServer() throws Exception { + CalculatorServer.main(new String[] {"1000"}); + } +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/README b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/README new file mode 100644 index 0000000000..3359bb74d5 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/README @@ -0,0 +1,2 @@ +The spring-bigbank-checkaccount module is part of the simple-bigbank-spring sample. +Please see the README file under simple-bigbank-spring to understand how spring-bigbank-checkaccount fits into the overall picture. diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/build.xml new file mode 100644 index 0000000000..dbf2addcc4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/build.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/pom.xml new file mode 100644 index 0000000000..99da32f52a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/pom.xml @@ -0,0 +1,145 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-spring-bigbank-checkaccount + Apache Tuscany SCA Sample Spring-Based BigBank Checking Accounts + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-policy-security + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-core-spi + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-spring + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-spring-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-jms-asf + 1.6.2 + + + + org.springframework + spring-core + 2.5.5 + + + + org.springframework + spring-beans + 2.5.5 + + + + org.springframework + spring-context + 2.5.5 + + + + org.apache.ws.security + wss4j + 1.5.3 + + + + junit + junit + 4.5 + test + + + + org.apache.activemq + activemq-core + 5.2.0 + + + backport-util-concurrent + backport-util-concurrent + 3.1 + + + + + ${artifactId} + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountDetails.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/server/CheckingAccountServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/server/CheckingAccountServer.java new file mode 100644 index 0000000000..562314230a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/checking/server/CheckingAccountServer.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 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) { + long timeout = -1L; + if (args.length > 0) { + timeout = Long.parseLong(args[0]); + } + + 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(); + + if (timeout < 0) { + System.out.println("CheckingsAccount server started (press enter to shutdown)"); + System.in.read(); + } else { + Thread.sleep(timeout); + } + + 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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/AccountsDataPasswordCallbackHandler.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/BigbankCheckingsAcl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthImplementationPolicyProvider.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicy.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyInterceptor.java b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyInterceptor.java new file mode 100644 index 0000000000..5c692df4ec --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyInterceptor.java @@ -0,0 +1,73 @@ +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; +import org.apache.tuscany.sca.policy.SecurityUtil; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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(); + Principal principal = SecurityUtil.getPrincipal(msg); + if (principal != null){ + BigbankCheckingsAcl.authorize(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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyProviderFactory.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyHandler.java b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyHandler.java new file mode 100644 index 0000000000..b023adf907 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyHandler.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 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.SecurityUtil; +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(); + Principal principal = SecurityUtil.getPrincipal(msg); + if (principal != null){ + BigbankCheckingsAcl.authorize(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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyProcessor.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/resources/CheckingsAccount.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/resources/CheckingsAccount.composite new file mode 100644 index 0000000000..371a1afd32 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/resources/CheckingsAccount.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/resources/definitions.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/resources/definitions.xml new file mode 100644 index 0000000000..0ce1440ddf --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/main/resources/spring-context/META-INF/spring/CheckingAccountService-context.xml b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/test/java/bigbank/checkaccount/CheckAccountServiceTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/test/java/bigbank/checkaccount/CheckAccountServiceTestCase.java new file mode 100644 index 0000000000..a45630278b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-checkaccount/src/test/java/bigbank/checkaccount/CheckAccountServiceTestCase.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.checkaccount; + +import junit.framework.TestCase; +import bigbank.account.checking.server.CheckingAccountServer; + +/** + * Tests out the big bank service + * + */ +public class CheckAccountServiceTestCase extends TestCase { + + public void testServer() throws Exception { + CheckingAccountServer.main(new String[] {"1000"}); + } +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/README b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/README new file mode 100644 index 0000000000..023af38b24 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/README @@ -0,0 +1,2 @@ +The spring-bigbank-stockquote module is part of the simple-bigbank-spring sample. +Please see the README file under simple-bigbank-spring to understand how spring-bigbank-stockquote fits into the overall picture. diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/build.xml new file mode 100644 index 0000000000..2e0300ed8c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/pom.xml new file mode 100644 index 0000000000..f031b9c251 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/pom.xml @@ -0,0 +1,117 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-spring-bigbank-stockquote + Apache Tuscany SCA Sample Spring-Based BigBank StockQuote + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-api + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-spring + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-spring-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.2 + runtime + + + + org.springframework + spring-core + 2.5.5 + + + + org.springframework + spring-beans + 2.5.5 + + + + org.springframework + spring-context + 2.5.5 + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/StockQuoteImpl.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/StockQuoteService.java b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/SCAApplicationContextProvider.java b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/SCAApplicationContextProvider.java new file mode 100644 index 0000000000..cbe0570805 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/SCAApplicationContextProvider.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package 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/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/StockQuoteServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/StockQuoteServer.java new file mode 100644 index 0000000000..da96f29b0c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/java/bigbank/stockquote/server/StockQuoteServer.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 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 { + long timeout = -1L; + if (args.length > 0) { + timeout = Long.parseLong(args[0]); + } + + 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..."); + + 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/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/resources/META-INF/spring/StockQuoteService-context.xml b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/resources/StockQuote.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/resources/StockQuote.composite new file mode 100644 index 0000000000..06544c6883 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/main/resources/StockQuote.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/test/java/bigbank/stockquote/StockQuoteServiceTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/test/java/bigbank/stockquote/StockQuoteServiceTestCase.java new file mode 100644 index 0000000000..4b36d0694d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/spring-bigbank-stockquote/src/test/java/bigbank/stockquote/StockQuoteServiceTestCase.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.stockquote; + +import junit.framework.TestCase; +import bigbank.stockquote.server.StockQuoteServer; + +/** + * Tests out the big bank service + * + */ +public class StockQuoteServiceTestCase extends TestCase { + + public void testServer() throws Exception { + StockQuoteServer.main(new String[] {"1000"}); + } +} diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/README b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/README new file mode 100644 index 0000000000..8e9bbb9165 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/README @@ -0,0 +1,38 @@ +Store Dojo Sample +====================================== + +This sample demonstrates how the Dojo Toolkit can be used to implement the user interface of the sample store scenario +that is used as a getting started guide for Tuscany SCA. For detailed information on this scenario, 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 + + +Running And Building The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be run using Ant as follows: + +cd store-dojo +ant run + +Once the application is running use your browser to visit the following +URL: + +http://localhost:8080/store/ + +If you want to build it before running it, you can do: + +cd store-dojo +ant compile +ant run + +Building The Sample Using Maven +------------------------------- +With the source and binary distributions the sample can be built using Maven +as follows: + +cd store-dojo +mvn diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/pom.xml new file mode 100644 index 0000000000..7d5234b8e9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/pom.xml @@ -0,0 +1,144 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../pom.xml + + sample-store-dojo + Apache Tuscany SCA Sample Getting Started Online Store Dojo + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-data-api + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-web-javascript-dojo + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-widget-runtime-dojo + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-js-dojo + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-js-dojo + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.6.2 + + + + generate + + + launch.Launch + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/launch/Launch.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/launch/Launch.java new file mode 100644 index 0000000000..801697abea --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-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("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/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/Cart.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/Cart.java new file mode 100644 index 0000000000..9e6226d963 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/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/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/Catalog.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/Catalog.java new file mode 100644 index 0000000000..2c3b19f579 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/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/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/CurrencyConverter.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/CurrencyConverter.java new file mode 100644 index 0000000000..e104a0423a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/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/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/CurrencyConverterImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/CurrencyConverterImpl.java new file mode 100644 index 0000000000..c354aed447 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/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/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/FruitsCatalogImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/FruitsCatalogImpl.java new file mode 100644 index 0000000000..377b3d7e59 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/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/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/Item.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/Item.java new file mode 100644 index 0000000000..27abd4f016 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/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/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/ShoppingCartImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/ShoppingCartImpl.java new file mode 100644 index 0000000000..9889921a96 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/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/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/Total.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/java/services/Total.java new file mode 100644 index 0000000000..8f464e526f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/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/tags/1.6.2-RC1/samples/store-dojo/src/main/resources/store.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/resources/store.composite new file mode 100644 index 0000000000..571678839d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/resources/store.composite @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/resources/uiservices/store.html b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/resources/uiservices/store.html new file mode 100644 index 0000000000..8fd22f4123 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/src/main/resources/uiservices/store.html @@ -0,0 +1,168 @@ + + + +Store + + + + + + + + + + + + +

Store

+
+

Catalog

+
+
+
+ +
+ +
+ +

Your Shopping Cart

+
+
+
+
+
+ + + (feed) +
+
+ + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/store.png b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/store.png new file mode 100644 index 0000000000..da413edeee Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/store.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/store.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/store.svg new file mode 100644 index 0000000000..74f8ecd36d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-dojo/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/tags/1.6.2-RC1/samples/store-secure/README b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/README new file mode 100644 index 0000000000..c4eaa64d21 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/README @@ -0,0 +1,40 @@ +Secure Store Sample +====================================== + +This sample demonstrates how HTTP basic authentication can be added to the sample store scenario that is used +as a getting started guide for Tuscany SCA. For detailed information on this scenario, 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 + + +Running And Building The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be run using Ant as follows: + +cd store-secure +ant run + +Once the application is running use your browser to visit the following +URL: + +http://localhost:8080/store/ + +You will be prompted for a username and password. It doesn't matter what values you enter. + +If you want to build it before running it, you can do: + +cd store-secure +ant compile +ant run + +Building The Sample Using Maven +------------------------------- +With the source and binary distributions the sample can be built using Maven +as follows: + +cd store-secure +mvn diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/build.xml new file mode 100644 index 0000000000..2febcdbdcc --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/pom.xml new file mode 100644 index 0000000000..7ac566c04f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/pom.xml @@ -0,0 +1,126 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../pom.xml + + sample-store-secure + Apache Tuscany SCA Sample Getting Started Online Store Secure + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-policy-security-http + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-data-api + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-widget-runtime-tuscany + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-js + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-js + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/launch/Launch.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/launch/Launch.java new file mode 100644 index 0000000000..801697abea --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/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/tags/1.6.2-RC1/samples/store-secure/src/main/java/launch/LaunchProtected.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/launch/LaunchProtected.java new file mode 100644 index 0000000000..ffdf9db47b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/launch/LaunchProtected.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 LaunchProtected { + public static void main(String[] args) throws Exception { + System.out.println("Starting ..."); + SCADomain scaDomain = SCADomain.newInstance("store-protected.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/tags/1.6.2-RC1/samples/store-secure/src/main/java/launch/LaunchSSL.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/launch/LaunchSSL.java new file mode 100644 index 0000000000..a3703869ac --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/launch/LaunchSSL.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 LaunchSSL { + public static void main(String[] args) throws Exception { + System.out.println("Starting ..."); + SCADomain scaDomain = SCADomain.newInstance("store-ssl.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/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/Cart.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/Cart.java new file mode 100644 index 0000000000..9e6226d963 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/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/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/Catalog.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/Catalog.java new file mode 100644 index 0000000000..2c3b19f579 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/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/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/CurrencyConverter.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/CurrencyConverter.java new file mode 100644 index 0000000000..e104a0423a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/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/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/CurrencyConverterImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/CurrencyConverterImpl.java new file mode 100644 index 0000000000..c354aed447 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/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/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/FruitsCatalogImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/FruitsCatalogImpl.java new file mode 100644 index 0000000000..377b3d7e59 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/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/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/Item.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/Item.java new file mode 100644 index 0000000000..27abd4f016 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/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/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/ShoppingCartImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/ShoppingCartImpl.java new file mode 100644 index 0000000000..9889921a96 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/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/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/Total.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/java/services/Total.java new file mode 100644 index 0000000000..8f464e526f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/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/tags/1.6.2-RC1/samples/store-secure/src/main/resources/definitions.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/definitions.xml new file mode 100644 index 0000000000..140c5fd1c5 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/definitions.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/store-protected.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/store-protected.composite new file mode 100644 index 0000000000..5619afd8d9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/store-protected.composite @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/store-ssl.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/store-ssl.composite new file mode 100644 index 0000000000..79ef3f31a3 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/store-ssl.composite @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/store.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/store.composite new file mode 100644 index 0000000000..8aef45c53c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/store.composite @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/tuscany.keyStore b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/tuscany.keyStore new file mode 100644 index 0000000000..7ea23f7ff4 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/tuscany.keyStore differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/uiservices/store.html b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/uiservices/store.html new file mode 100644 index 0000000000..ba004e02ac --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/src/main/resources/uiservices/store.html @@ -0,0 +1,162 @@ + + + +Store + + + + + + + + +

Store

+
+

Catalog

+
+
+
+ +
+ +
+ +

Your Shopping Cart

+
+
+
+
+
+ + + (feed) +
+
+ + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/store.png b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/store.png new file mode 100644 index 0000000000..da413edeee Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/store.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/store.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/store.svg new file mode 100644 index 0000000000..74f8ecd36d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-secure/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/tags/1.6.2-RC1/samples/store-webapp/README b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/README new file mode 100644 index 0000000000..d8f253efa0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/README @@ -0,0 +1,41 @@ +Store Web Application Sample +============================ + +This sample demonstrates how the sample store scenario that is used as a getting started guide for Tuscany SCA +can be packaged and deployed as a web application. For detailed information on this scenario, 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 + + +Running The Sample +------------------ +As this sample provides a web application there is a manual step where the WAR file +that contains the sample is is built and copied to your web application container. +See the sections below for instructions on building the WAR file. + +Once the web application is deployed use your browser to visit the following URL; + + http://localhost:8080/sample-store-webapp + +The port and hostname will of course vary depending on your local installation. + + +Building The Sample Using Ant +----------------------------- +With the binary distribution the sample can be built using Ant as follows: + +cd store-webapp +ant package + + +Building The Sample Using Maven +------------------------------- +With the source and binary distributions the sample can be built using Maven +as follows: + +cd store-webapp +mvn diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/pom.xml new file mode 100644 index 0000000000..a6559795bf --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/pom.xml @@ -0,0 +1,122 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../pom.xml + + sample-store-webapp + war + Apache Tuscany SCA Sample Getting Started Online Store as WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-data-api + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-widget-runtime-tuscany + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-js + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.6.2 + runtime + + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-js + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.6.2 + + + + generate + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/Cart.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/Cart.java new file mode 100644 index 0000000000..9e6226d963 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/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/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/Catalog.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/Catalog.java new file mode 100644 index 0000000000..2c3b19f579 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/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/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/CurrencyConverter.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/CurrencyConverter.java new file mode 100644 index 0000000000..e104a0423a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/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/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/CurrencyConverterImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/CurrencyConverterImpl.java new file mode 100644 index 0000000000..c354aed447 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/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/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/FruitsCatalogImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/FruitsCatalogImpl.java new file mode 100644 index 0000000000..377b3d7e59 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/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/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/Item.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/Item.java new file mode 100644 index 0000000000..27abd4f016 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/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/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/ShoppingCartImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/ShoppingCartImpl.java new file mode 100644 index 0000000000..9889921a96 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/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/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/Total.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/java/services/Total.java new file mode 100644 index 0000000000..8f464e526f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/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/tags/1.6.2-RC1/samples/store-webapp/src/main/resources/store.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/resources/store.composite new file mode 100644 index 0000000000..9c25783c0f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/resources/store.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..41c84c9a44 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..d191961f95 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,50 @@ + + + + + + org.apache.tuscany + sample-store-secure-webapp + 1.0 + car + + + + + org.apache.axiom + org.apache.axis2 + org.apache.commons + org.jdom + + + + /sample-store-secure-webapp + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..348be0df21 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,36 @@ + + + + sample-store-secure-webapp + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + store.html + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/store.html b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/store.html new file mode 100644 index 0000000000..ba004e02ac --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/src/main/webapp/store.html @@ -0,0 +1,162 @@ + + + +Store + + + + + + + + +

Store

+
+

Catalog

+
+
+
+ +
+ +
+ +

Your Shopping Cart

+
+
+
+
+
+ + + (feed) +
+
+ + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/store.png b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/store.png new file mode 100644 index 0000000000..da413edeee Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/store.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/store.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/store.svg new file mode 100644 index 0000000000..74f8ecd36d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store-webapp/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/tags/1.6.2-RC1/samples/store/README b/sca-java-1.x/tags/1.6.2-RC1/samples/store/README new file mode 100644 index 0000000000..16a82fe0c1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store/README @@ -0,0 +1,38 @@ +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 + + +Running And Building The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be run using Ant as follows: + +cd store +ant run + +Once the application is running use your browser to visit the following +URL: + +http://localhost:8080/store/ + +If you want to build it before running it, you can do: + +cd store +ant compile +ant run + +Building The Sample Using Maven +------------------------------- +With the source and binary distributions the sample can be built using Maven +as follows: + +cd store +mvn diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/store/build.xml new file mode 100644 index 0000000000..448524bb94 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/store/pom.xml new file mode 100644 index 0000000000..eaa14d5a87 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store/pom.xml @@ -0,0 +1,121 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../pom.xml + + sample-store + Apache Tuscany SCA Sample Getting Started Online Store + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-data-api + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-widget-runtime-tuscany + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-js + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-js + 1.6.2 + runtime + + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/launch/Launch.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/launch/Launch.java new file mode 100644 index 0000000000..801697abea --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/store/src/main/java/services/Cart.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/Cart.java new file mode 100644 index 0000000000..9e6226d963 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/store/src/main/java/services/Catalog.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/Catalog.java new file mode 100644 index 0000000000..2c3b19f579 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/store/src/main/java/services/CurrencyConverter.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/CurrencyConverter.java new file mode 100644 index 0000000000..e104a0423a --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/store/src/main/java/services/CurrencyConverterImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/CurrencyConverterImpl.java new file mode 100644 index 0000000000..c354aed447 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/store/src/main/java/services/FruitsCatalogImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/FruitsCatalogImpl.java new file mode 100644 index 0000000000..377b3d7e59 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/store/src/main/java/services/Item.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/Item.java new file mode 100644 index 0000000000..27abd4f016 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/store/src/main/java/services/ShoppingCartImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/ShoppingCartImpl.java new file mode 100644 index 0000000000..9889921a96 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/store/src/main/java/services/Total.java b/sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/java/services/Total.java new file mode 100644 index 0000000000..8f464e526f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/store/src/main/resources/store.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/resources/store.composite new file mode 100644 index 0000000000..571678839d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/resources/store.composite @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/resources/uiservices/store.html b/sca-java-1.x/tags/1.6.2-RC1/samples/store/src/main/resources/uiservices/store.html new file mode 100644 index 0000000000..ba004e02ac --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/store/store.png b/sca-java-1.x/tags/1.6.2-RC1/samples/store/store.png new file mode 100644 index 0000000000..da413edeee Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/store/store.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/store/store.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/store/store.svg new file mode 100644 index 0000000000..74f8ecd36d --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/supplychain/README b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/README new file mode 100644 index 0000000000..ea4493fdd4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/supplychain/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/build.xml new file mode 100644 index 0000000000..6651359d20 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/pom.xml new file mode 100644 index 0000000000..ef3c137f14 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-supplychain + Apache Tuscany SCA Sample Supply Chain + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/Customer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/Customer.java new file mode 100644 index 0000000000..8088001898 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/CustomerComponentImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/CustomerComponentImpl.java new file mode 100644 index 0000000000..7a1e8553ec --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/Retailer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/Retailer.java new file mode 100644 index 0000000000..1add63fb4e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/RetailerComponentImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/RetailerComponentImpl.java new file mode 100644 index 0000000000..f622052cf8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/Shipper.java b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/Shipper.java new file mode 100644 index 0000000000..d4d49a922b --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/ShipperComponentImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/ShipperComponentImpl.java new file mode 100644 index 0000000000..4ae52a12a2 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/SupplyChainClient.java b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/SupplyChainClient.java new file mode 100644 index 0000000000..7072f582d1 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/Warehouse.java b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/Warehouse.java new file mode 100644 index 0000000000..0be499f569 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/WarehouseComponentImpl.java b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/java/supplychain/WarehouseComponentImpl.java new file mode 100644 index 0000000000..b5e256a1e0 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/supplychain/src/main/resources/supplychain.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/resources/supplychain.composite new file mode 100644 index 0000000000..301efcaf1f --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/main/resources/supplychain.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java new file mode 100644 index 0000000000..88e0eb7ab8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/supplychain/supplychain.png b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/supplychain.png new file mode 100644 index 0000000000..51a384e827 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/supplychain.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/supplychain.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/supplychain.svg new file mode 100644 index 0000000000..f72e77acab --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/supplychain/supplychain.svg @@ -0,0 +1,228 @@ + + + + + + + + + + image/svg+xml + + + + + + + + supplychain + + CustomerComponent + + + RetailerComponent + + + WharehouseComponent + + + ShipperComponent + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/README b/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/README new file mode 100644 index 0000000000..56bffba6a3 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/web-resource/build.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/build.xml new file mode 100644 index 0000000000..c196416dd8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/build.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/pom.xml b/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/pom.xml new file mode 100644 index 0000000000..98d3aad98e --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.2 + ../../pom.xml + + sample-web-resource + Apache Tuscany SCA Sample Web Resource + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-implementation-resource-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.6.2 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/src/main/java/web/resource/SampleServer.java b/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/src/main/java/web/resource/SampleServer.java new file mode 100644 index 0000000000..9410de08c4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/web-resource/src/main/resources/WebResource.composite b/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/src/main/resources/WebResource.composite new file mode 100644 index 0000000000..66b8f25e17 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/src/main/resources/WebResource.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/src/main/resources/myContent/index.html b/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/src/main/resources/myContent/index.html new file mode 100644 index 0000000000..55de048373 --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/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/tags/1.6.2-RC1/samples/web-resource/web-resource.png b/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/web-resource.png new file mode 100644 index 0000000000..7259447b65 Binary files /dev/null and b/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/web-resource.png differ diff --git a/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/web-resource.svg b/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/web-resource.svg new file mode 100644 index 0000000000..0d1257316c --- /dev/null +++ b/sca-java-1.x/tags/1.6.2-RC1/samples/web-resource/web-resource.svg @@ -0,0 +1,197 @@ + + + + + + + + + + image/svg+xml + + + + + + + + WebResource + + + myWeb + implementation.resource + + File System + ./myContent /index.html + + binding.http + + -- cgit v1.2.3