From a40e527938d76ba71f211da7e327adb50384ba69 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:26:33 +0000 Subject: Moving 1.x tags git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835157 13f79535-47bb-0310-9956-ffa450edef68 --- .../tags/1.4/demos/alert-aggregator-webapp/README | 82 +++ .../alert-aggregator-webapp/alert-aggregator.png | Bin 0 -> 36819 bytes .../alert-aggregator-webapp/alert-aggregator.svg | 627 +++++++++++++++++++++ .../demos/alert-aggregator-webapp/build-dojo.xml | 92 +++ .../1.4/demos/alert-aggregator-webapp/build.xml | 148 +++++ .../tags/1.4/demos/alert-aggregator-webapp/pom.xml | 356 ++++++++++++ .../sca/demos/aggregator/AlertTypeNonSDOImpl.java | 339 +++++++++++ .../demos/aggregator/AlertsFeedServiceImpl.java | 106 ++++ .../sca/demos/aggregator/AlertsService.java | 40 ++ .../sca/demos/aggregator/AlertsServiceImpl.java | 126 +++++ .../sca/demos/aggregator/AlertsSourcesService.java | 69 +++ .../demos/aggregator/AlertsSourcesServiceImpl.java | 183 ++++++ .../sca/demos/aggregator/AlertsTypeNonSDOImpl.java | 74 +++ .../sca/demos/aggregator/ConfigTypeNonSDOImpl.java | 55 ++ .../sca/demos/aggregator/RSSCheckerService.java | 30 + .../demos/aggregator/RSSCheckerServiceImpl.java | 91 +++ .../sca/demos/aggregator/SourceTypeNonSDOImpl.java | 536 ++++++++++++++++++ .../src/main/resources/Alerts.wsdl | 88 +++ .../src/main/resources/Alerts.xsd | 80 +++ .../src/main/resources/AlertsSources.wsdl | 124 ++++ .../src/main/resources/alerts-client.composite | 49 ++ .../src/main/resources/alerts.composite | 85 +++ .../src/main/resources/sources.xml | 34 ++ .../src/main/webapp/AlertAggregator.html | 330 +++++++++++ .../src/main/webapp/META-INF/sca-contribution.xml | 25 + .../src/main/webapp/WEB-INF/geronimo-web.xml | 37 ++ .../src/main/webapp/WEB-INF/web.xml | 41 ++ .../src/main/webapp/pop.png | Bin 0 -> 244 bytes .../src/main/webapp/rss.png | Bin 0 -> 689 bytes .../src/main/webapp/service.smd | 1 + .../src/main/webapp/sources.smd | 1 + .../src/main/webapp/style.css | 176 ++++++ .../demos/aggregator/AlertsIntegrationTest.java | 97 ++++ sca-java-1.x/tags/1.4/demos/bigbank-account/README | 4 + .../tags/1.4/demos/bigbank-account/bigbank.png | Bin 0 -> 100070 bytes .../tags/1.4/demos/bigbank-account/bigbank.svg | 537 ++++++++++++++++++ .../tags/1.4/demos/bigbank-account/build-dojo.xml | 92 +++ .../tags/1.4/demos/bigbank-account/build.xml | 85 +++ .../tags/1.4/demos/bigbank-account/pom.xml | 76 +++ .../account/checking/CheckingAccountDetails.java | 50 ++ .../account/checking/CheckingAccountService.java | 37 ++ .../checking/CheckingAccountServiceImpl.java | 66 +++ .../account/savings/SavingsAccountDetails.java | 52 ++ .../account/savings/SavingsAccountService.java | 35 ++ .../account/savings/SavingsAccountServiceImpl.java | 66 +++ .../AccountsDataPasswordCallbackHandler.java | 54 ++ .../account/security/BigbankCheckingsAcl.java | 48 ++ ...ckingsDeptAuthImplementationPolicyProvider.java | 90 +++ .../account/security/CheckingsDeptAuthPolicy.java | 46 ++ .../CheckingsDeptAuthPolicyInterceptor.java | 79 +++ .../CheckingsDeptAuthPolicyProviderFactory.java | 75 +++ .../CheckingsDeptAuthorizationPolicyHandler.java | 67 +++ .../CheckingsDeptAuthorizationPolicyProcessor.java | 72 +++ .../bigbank/account/stock/StockAccountDetails.java | 68 +++ .../bigbank/account/stock/StockAccountService.java | 36 ++ .../account/stock/StockAccountServiceImpl.java | 60 ++ .../src/main/resources/CheckingsAccount.composite | 35 ++ .../main/resources/META-INF/sca-contribution.xml | 41 ++ ...ca.contribution.processor.StAXArtifactProcessor | 19 + ...rg.apache.tuscany.sca.policy.util.PolicyHandler | 20 + ...ache.tuscany.sca.provider.PolicyProviderFactory | 19 + .../src/main/resources/SavingsAccount.composite | 34 ++ .../src/main/resources/StockAccount.composite | 34 ++ .../src/main/resources/definitions.xml | 58 ++ .../src/main/resources/web/AccountJSON.html | 92 +++ .../src/main/resources/web/style.css | 22 + .../src/main/resources/wsdl/AccountService.wsdl | 91 +++ .../tags/1.4/demos/bigbank-calculator/README | 2 + .../tags/1.4/demos/bigbank-calculator/build.xml | 68 +++ .../tags/1.4/demos/bigbank-calculator/pom.xml | 78 +++ .../src/main/java/calculator/AddService.java | 25 + .../main/java/calculator/CalculatorService.java | 34 ++ .../java/calculator/CalculatorServiceImpl.java | 72 +++ .../src/main/java/calculator/DivideService.java | 25 + .../src/main/java/calculator/MultiplyService.java | 25 + .../src/main/java/calculator/SubtractService.java | 25 + .../java/calculator/demo/CalculatorServer.java | 44 ++ .../src/main/resources/Calculator.composite | 55 ++ .../main/resources/calculator/AddServiceImpl.js | 22 + .../resources/calculator/DivideServiceImpl.groovy | 22 + .../resources/calculator/MultiplyServiceImpl.py | 21 + .../resources/calculator/SubtractServiceImpl.rb | 22 + .../tags/1.4/demos/bigbank-stockquote/README | 4 + .../tags/1.4/demos/bigbank-stockquote/build.xml | 67 +++ .../tags/1.4/demos/bigbank-stockquote/pom.xml | 85 +++ .../java/stockquote/PasswordCallbackHandler.java | 47 ++ .../src/main/java/stockquote/StockQuoteImpl.java | 38 ++ .../main/java/stockquote/StockQuoteService.java | 30 + .../java/stockquote/demo/StockQuoteServer.java | 42 ++ .../src/main/resources/StockQuote.composite | 33 ++ .../src/main/resources/definitions.xml | 49 ++ .../src/main/resources/security.properties | 20 + .../src/main/resources/stockQuote.jks | Bin 0 -> 1986 bytes sca-java-1.x/tags/1.4/demos/bigbank/README | 114 ++++ sca-java-1.x/tags/1.4/demos/bigbank/bigbank.png | Bin 0 -> 100070 bytes sca-java-1.x/tags/1.4/demos/bigbank/bigbank.svg | 537 ++++++++++++++++++ sca-java-1.x/tags/1.4/demos/bigbank/build-dojo.xml | 92 +++ sca-java-1.x/tags/1.4/demos/bigbank/build.xml | 84 +++ sca-java-1.x/tags/1.4/demos/bigbank/pom.xml | 201 +++++++ .../main/java/bigbank/account/AccountService.java | 32 ++ .../java/bigbank/account/AccountServiceImpl.java | 99 ++++ .../java/bigbank/account/feed/AccountFeedImpl.java | 70 +++ .../main/java/bigbank/client/BigBankClient.java | 50 ++ .../src/main/java/bigbank/demo/BigBankServer.java | 130 +++++ .../security/BigbankPasswordCallbackHandler.java | 51 ++ .../main/java/calculator/CalculatorService.java | 34 ++ .../main/java/stockquote/StockQuoteService.java | 29 + .../bigbank/src/main/resources/BigBank.composite | 85 +++ .../main/resources/META-INF/sca-contribution.xml | 35 ++ .../demos/bigbank/src/main/resources/bigbank.jks | Bin 0 -> 1986 bytes .../bigbank/src/main/resources/definitions.xml | 64 +++ .../bigbank/src/main/resources/security.properties | 20 + .../src/main/resources/web/AccountJSON.html | 92 +++ .../demos/bigbank/src/main/resources/web/style.css | 22 + .../src/main/resources/wsdl/AccountService.wsdl | 91 +++ .../src/test/java/test/BigBankTestCase.java | 33 ++ .../tags/1.4/demos/mortgage-creditcheck/README | 6 + .../tags/1.4/demos/mortgage-creditcheck/build.xml | 66 +++ .../tags/1.4/demos/mortgage-creditcheck/pom.xml | 75 +++ .../src/main/java/credit/CreditCheck.java | 26 + .../src/main/java/credit/CreditCheckImpl.java | 34 ++ .../src/main/java/credit/CreditCheckServer.java | 40 ++ .../src/main/resources/CreditCheck.composite | 37 ++ .../src/main/resources/wsdl/credit.wsdl | 81 +++ .../src/main/webapp/META-INF/sca-contribution.xml | 23 + .../src/main/webapp/WEB-INF/web.xml | 37 ++ .../tags/1.4/demos/mortgage-loanapproval/README | 60 ++ .../tags/1.4/demos/mortgage-loanapproval/build.xml | 66 +++ .../mortgage-loanapproval/doc/credit_composite.jpg | Bin 0 -> 73610 bytes .../mortgage-loanapproval/doc/credit_composite.png | Bin 0 -> 51153 bytes .../mortgage-loanapproval/doc/loan_approval.jpg | Bin 0 -> 162536 bytes .../mortgage-loanapproval/doc/loan_approval.png | Bin 0 -> 58247 bytes .../doc/mortgage_assembly0.jpg | Bin 0 -> 145053 bytes .../doc/mortgage_assembly0.png | Bin 0 -> 93773 bytes .../doc/mortgage_assembly1.jpg | Bin 0 -> 181317 bytes .../doc/mortgage_assembly1.png | Bin 0 -> 113404 bytes .../doc/mortgage_assembly2.jpg | Bin 0 -> 180240 bytes .../doc/mortgage_assembly2.png | Bin 0 -> 106656 bytes .../doc/mortgage_composite.jpg | Bin 0 -> 343699 bytes .../doc/mortgage_composite.png | Bin 0 -> 288351 bytes .../doc/mortgage_diagrams.doc | Bin 0 -> 81920 bytes .../doc/mortgage_package1.jpg | Bin 0 -> 181031 bytes .../doc/mortgage_package1.png | Bin 0 -> 34939 bytes .../doc/mortgage_package2.jpg | Bin 0 -> 110930 bytes .../doc/mortgage_package2.png | Bin 0 -> 58993 bytes .../doc/mortgage_scenario.jpg | Bin 0 -> 225690 bytes .../doc/mortgage_scenario.png | Bin 0 -> 106791 bytes .../mortgage-loanapproval/mortgage_assembly.png | Bin 0 -> 106656 bytes .../tags/1.4/demos/mortgage-loanapproval/pom.xml | 83 +++ .../src/main/java/mortgage/CreditCheck.java | 29 + .../src/main/java/mortgage/CreditCheckImpl.java | 34 ++ .../src/main/java/mortgage/Customer.java | 76 +++ .../src/main/java/mortgage/InterestRateQuote.java | 23 + .../main/java/mortgage/InterestRateQuoteImpl.java | 42 ++ .../src/main/java/mortgage/LoanApproval.java | 27 + .../src/main/java/mortgage/LoanApprovalImpl.java | 84 +++ .../src/main/java/mortgage/MortgageCalculator.java | 29 + .../main/java/mortgage/MortgageCalculatorImpl.java | 38 ++ .../src/main/java/mortgage/MortgageClient.java | 44 ++ .../src/main/java/mortgage/RiskAssessment.java | 27 + .../src/main/java/mortgage/RiskAssessmentImpl.java | 38 ++ .../src/main/resources/Mortgage.composite | 48 ++ .../src/main/resources/Mortgage1.composite | 57 ++ .../resources/MortgageCalculator.componentType | 27 + .../src/main/resources/MortgageCalculator.js | 25 + .../src/main/resources/wsdl/credit.wsdl | 81 +++ .../test/java/mortgage/MortgageClientTestCase.java | 56 ++ sca-java-1.x/tags/1.4/demos/pom.xml | 52 ++ sca-java-1.x/tags/1.4/demos/xml-bigbank/README | 46 ++ sca-java-1.x/tags/1.4/demos/xml-bigbank/build.xml | 63 +++ sca-java-1.x/tags/1.4/demos/xml-bigbank/pom.xml | 115 ++++ .../src/main/java/bigbank/AccountData.java | 36 ++ .../src/main/java/bigbank/AccountDataImpl.java | 48 ++ .../src/main/java/bigbank/AccountService.java | 32 ++ .../src/main/java/bigbank/AccountServiceImpl.java | 84 +++ .../src/main/java/bigbank/BigBankClient.java | 35 ++ .../src/main/java/bigbank/BigBankServer.java | 40 ++ .../src/main/java/bigbank/CurrencyExchange.java | 36 ++ .../src/main/java/bigbank/ExchangeRate.java | 32 ++ .../src/main/java/bigbank/ExchangeRateImpl.java | 84 +++ .../src/main/java/bigbank/StockQuote.java | 38 ++ .../src/main/java/bigbank/StockValue.java | 38 ++ .../src/main/resources/BigBank.composite | 51 ++ .../xml-bigbank/src/main/resources/accounts.xml | 29 + .../xml-bigbank/src/main/resources/customer.xsd | 46 ++ .../demos/xml-bigbank/src/main/resources/stock.xq | 52 ++ .../src/main/resources/wsdl/StockQuotes.wsdl | 23 + .../tags/1.4/demos/xml-bigbank/xml-bigbank.png | Bin 0 -> 30396 bytes .../tags/1.4/demos/xml-bigbank/xml-bigbank.svg | 447 +++++++++++++++ 189 files changed, 12148 insertions(+) create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/README create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/alert-aggregator.png create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/alert-aggregator.svg create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/build-dojo.xml create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/build.xml create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/pom.xml create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsService.java create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsServiceImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesService.java create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesServiceImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/ConfigTypeNonSDOImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerService.java create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerServiceImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/SourceTypeNonSDOImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/Alerts.wsdl create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/Alerts.xsd create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/AlertsSources.wsdl create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/alerts-client.composite create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/alerts.composite create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/sources.xml create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/AlertAggregator.html create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/pop.png create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/rss.png create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/service.smd create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/sources.smd create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/style.css create mode 100644 sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/test/java/org/apache/tuscany/sca/demos/aggregator/AlertsIntegrationTest.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/README create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/bigbank.png create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/bigbank.svg create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/build-dojo.xml create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/build.xml create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/pom.xml create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountDetails.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountService.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountDetails.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountService.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/AccountsDataPasswordCallbackHandler.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/BigbankCheckingsAcl.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthImplementationPolicyProvider.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicy.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyInterceptor.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyProviderFactory.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyHandler.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyProcessor.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountDetails.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountService.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/CheckingsAccount.composite create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/SavingsAccount.composite create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/StockAccount.composite create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/web/AccountJSON.html create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/web/style.css create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/wsdl/AccountService.wsdl create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-calculator/README create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-calculator/build.xml create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-calculator/pom.xml create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/demo/CalculatorServer.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/resources/calculator/AddServiceImpl.js create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/resources/calculator/DivideServiceImpl.groovy create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/resources/calculator/MultiplyServiceImpl.py create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/resources/calculator/SubtractServiceImpl.rb create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-stockquote/README create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-stockquote/build.xml create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-stockquote/pom.xml create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/java/stockquote/PasswordCallbackHandler.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/java/stockquote/StockQuoteImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/java/stockquote/StockQuoteService.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/java/stockquote/demo/StockQuoteServer.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/StockQuote.composite create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/security.properties create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/stockQuote.jks create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/README create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/bigbank.png create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/bigbank.svg create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/build-dojo.xml create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/build.xml create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/pom.xml create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/account/AccountService.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/account/AccountServiceImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/client/BigBankClient.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/demo/BigBankServer.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/stockquote/StockQuoteService.java create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/BigBank.composite create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/bigbank.jks create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/definitions.xml create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/security.properties create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/web/AccountJSON.html create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/web/style.css create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/wsdl/AccountService.wsdl create mode 100644 sca-java-1.x/tags/1.4/demos/bigbank/src/test/java/test/BigBankTestCase.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/README create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/build.xml create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/pom.xml create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheck.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheckImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheckServer.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/resources/CreditCheck.composite create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/resources/wsdl/credit.wsdl create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/README create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/build.xml create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/credit_composite.jpg create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/credit_composite.png create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/loan_approval.jpg create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/loan_approval.png create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly0.jpg create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly0.png create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly1.jpg create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly1.png create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly2.jpg create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly2.png create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_composite.jpg create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_composite.png create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_diagrams.doc create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package1.jpg create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package1.png create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package2.jpg create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package2.png create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_scenario.jpg create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_scenario.png create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/mortgage_assembly.png create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/pom.xml create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheck.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheckImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/Customer.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuote.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuoteImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApproval.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApprovalImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculator.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculatorImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageClient.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessment.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessmentImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/Mortgage.composite create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/Mortgage1.composite create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.componentType create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.js create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/wsdl/credit.wsdl create mode 100644 sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/test/java/mortgage/MortgageClientTestCase.java create mode 100644 sca-java-1.x/tags/1.4/demos/pom.xml create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/README create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/build.xml create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/pom.xml create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountData.java create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountDataImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountService.java create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/BigBankClient.java create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/BigBankServer.java create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/CurrencyExchange.java create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/ExchangeRate.java create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/ExchangeRateImpl.java create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/StockQuote.java create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/StockValue.java create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/BigBank.composite create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/accounts.xml create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/customer.xsd create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/stock.xq create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/wsdl/StockQuotes.wsdl create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/xml-bigbank.png create mode 100644 sca-java-1.x/tags/1.4/demos/xml-bigbank/xml-bigbank.svg (limited to 'sca-java-1.x/tags/1.4/demos') diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/README b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/README new file mode 100644 index 0000000000..3ec27ef65f --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/README @@ -0,0 +1,82 @@ +Apache Tuscany Alert Aggregator Demo +==================================== + +The alert aggregator demo provides an application, implemented using SCA, that +aggregates feeds together and exposes them using the following bindings. + +binding.ws +binding.jsonrpc +binding.feed + +The easiest way to get going is to build the demo + +cd alert-aggregator-webapp +ant package + +This will build a war file + +demo-alert-aggregator-webapp.war + +This war can be deployed to you web application container and tested (the war +has been tested with Tomcat 6.0.10). + +The Web Application +------------------- + +Once deployed point your browser at + +http://localhost:8080/demo-alert-aggregator-webapp + +Taking care to ensure the host name and port number match you local +configuration. + +This launches a Javascript application in the browser that uses JSONRPC +to contact the server and retrived a list of alert sources and alerts that +these sources are providing. + +There default sources that you see are stored in a file in the following +file + +demo-alert-aggregator-webapp/WEB-INF/classes/sources.xml + +This files has the following contents + + + + BBC News + http://news.bbc.co.uk/ + 10-Jun-2007 16:34:03 + http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml + + + Engadget + http://www.engadget.com + 10-Jun-2007 16:34:03 + http://www.engadget.com/rss.xml + + + +You may want to adjust the "LastChecked" values to change the number of +alerts that are displayed in the first instance + +Using A Feed Reader +------------------- + +As this SCA application also uses the binding.feed binding you can use your +favourite feed reader to read the aggregated alerts. To do this point your +feed reader at + +http://localhost:8080/demo-alert-aggregator-webapp/services/AlertsFeedServiceRSS + +Again taking care to ensure that the host name and port number match you +local configuration. + +Using Web Services +------------------ + +The SCA application also uses binding.ws to provide a SOAP/HTTP interface. +The demo client that uses this interface is not yet available. + + + + diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/alert-aggregator.png b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/alert-aggregator.png new file mode 100644 index 0000000000..ae429cca94 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/alert-aggregator.png differ diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/alert-aggregator.svg b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/alert-aggregator.svg new file mode 100644 index 0000000000..807416135e --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/alert-aggregator.svg @@ -0,0 +1,627 @@ + + + + + + + + + + image/svg+xml + + + + + + + + DisplayComposite - PHP + + Display + + + + + + AlerterComposite - Java + + AlertsService + + + + rest soap + + + soap + + RSS + + + AlertsSourcesService + + + + + + jsonrpc + + + + + soap + + soap + atom + jsonrpc + + + + + + + POP - Not done + + + + + + + + + HTML Web2.0 Thunderbird + + NNTP - Not done + + rss + + AlertFeedService + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/build-dojo.xml b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/build-dojo.xml new file mode 100644 index 0000000000..c31c9adee8 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/build-dojo.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/build.xml b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/build.xml new file mode 100644 index 0000000000..793aa05c06 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/build.xml @@ -0,0 +1,148 @@ + + +]> + + + &buildDependency; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/pom.xml b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/pom.xml new file mode 100644 index 0000000000..a0cd6c12c4 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/pom.xml @@ -0,0 +1,356 @@ + + + + 4.0.0 + + + org.apache.tuscany.sca + tuscany-demos + 1.4 + ../pom.xml + + + org.apache.tuscany.sca + demo-alert-aggregator-webapp + war + 1.4 + Apache Tuscany SCA Demo Alert Aggregator + http://cwiki.apache.org/TUSCANY + + + + junit + junit + 4.5 + test + + + httpunit + httpunit + 1.6.1 + test + + + org.apache.tuscany.sdo + tuscany-sdo-api-r2.1 + 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-binding-ws-axis2 + ${pom.version} + runtime + + + org.apache.tuscany.sca + tuscany-core-databinding + ${pom.version} + runtime + + + org.apache.tuscany.sca + tuscany-databinding-jaxb + ${pom.version} + runtime + + + org.apache.tuscany.sca + tuscany-databinding-sdo + ${pom.version} + compile + + + org.apache.tuscany.sca + tuscany-databinding-axiom + ${pom.version} + compile + + + org.apache.tuscany.sca + tuscany-host-embedded + ${pom.version} + compile + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + ${pom.version} + compile + + + org.apache.tuscany.sca + tuscany-interface-java-xml + ${pom.version} + compile + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4 + runtime + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.4 + runtime + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.4 + + + org.apache.tuscany.sca + tuscany-binding-rss-rome + 1.4 + + + org.codehaus.woodstox + wstx-asl + 3.2.4 + runtime + + + + + demo-alert-aggregator-webapp + + + org.codehaus.mojo + build-helper-maven-plugin + 1.0 + + + add-test-source + generate-sources + + add-test-source + + + + target/sdo-source + + + + + + + org.apache.tuscany.sdo + tuscany-sdo-plugin + 1.1.1 + + + generate-sdo + generate-sources + + + + ${basedir}/src/main/resources/Alerts.wsdl + org.apache.tuscany.sca.demos.aggregator.service + + + ${basedir}/src/main/resources/AlertsSources.wsdl + org.apache.tuscany.sca.demos.aggregator.sources + + + ${basedir}/src/main/resources/Alerts.xsd + org.apache.tuscany.sca.demos.aggregator.types + + + true + true + true + + + generate + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.1 + + + + ant + ant-trax + 1.6.5 + + + + + + install-dojo + validate + + run + + + + + + + + + + + copy-dojo-files + generate-resources + + run + + + + + + + + + + + + clean-dojo-files + clean + + run + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + surefire-it + integration-test + + test + + + + **/*AlertsIntegrationTest.java + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.0-alpha-5 + + + start-container + pre-integration-test + + start + + + + stop-container + post-integration-test + + stop + + + + + + jetty6x + embedded + + org.apache.commons.logging.impl.SimpleLog + + + false + + + 8085 + + + + + ${project.build.directory}/${project.build.finalName}.${project.packaging} + + http://localhost:8085/AlertsSourcesServiceJSONRPC + + + ${project.build.directory}/cargo-jetty + + + + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4 + + + + true + + + generate + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java new file mode 100644 index 0000000000..808374030c --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java @@ -0,0 +1,339 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.demos.aggregator; + +import org.apache.tuscany.sca.demos.aggregator.types.AlertType; + + +public class AlertTypeNonSDOImpl implements AlertType +{ + private static final long serialVersionUID = 670364038865656196L; + +/** + * The default value of the '{@link #getTitle() Title}' attribute. + * + * + * @see #getTitle() + * @generated + * @ordered + */ + protected static final String TITLE_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getTitle() Title}' attribute. + * + * + * @see #getTitle() + * @generated + * @ordered + */ + protected String title = TITLE_DEFAULT_; + + /** + * The default value of the '{@link #getSummary() Summary}' attribute. + * + * + * @see #getSummary() + * @generated + * @ordered + */ + protected static final String SUMMARY_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getSummary() Summary}' attribute. + * + * + * @see #getSummary() + * @generated + * @ordered + */ + protected String summary = SUMMARY_DEFAULT_; + + /** + * The default value of the '{@link #getAddress() Address}' attribute. + * + * + * @see #getAddress() + * @generated + * @ordered + */ + protected static final String ADDRESS_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getAddress() Address}' attribute. + * + * + * @see #getAddress() + * @generated + * @ordered + */ + protected String address = ADDRESS_DEFAULT_; + + /** + * The default value of the '{@link #getDate() Date}' attribute. + * + * + * @see #getDate() + * @generated + * @ordered + */ + protected static final String DATE_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getDate() Date}' attribute. + * + * + * @see #getDate() + * @generated + * @ordered + */ + protected String date = DATE_DEFAULT_; + + /** + * The default value of the '{@link #getSourceId() Source Id}' attribute. + * + * + * @see #getSourceId() + * @generated + * @ordered + */ + protected static final String SOURCE_ID_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getSourceId() Source Id}' attribute. + * + * + * @see #getSourceId() + * @generated + * @ordered + */ + protected String sourceId = SOURCE_ID_DEFAULT_; + + /** + * The default value of the '{@link #isUnread() Unread}' attribute. + * + * + * @see #isUnread() + * @generated + * @ordered + */ + protected static final boolean UNREAD_DEFAULT_ = false; + + /** + * The cached value of the '{@link #isUnread() Unread}' attribute. + * + * + * @see #isUnread() + * @generated + * @ordered + */ + protected boolean unread = UNREAD_DEFAULT_; + + /** + * The default value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected static final String ID_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected String id = ID_DEFAULT_; + + /** + * + * + * @generated + */ + public AlertTypeNonSDOImpl() + { + super(); + } + + + /** + * + * + * @generated + */ + public String getTitle() + { + return title; + } + /** + * + * + * @generated + */ + public void setTitle(String newTitle) + { + title = newTitle; + } + + /** + * + * + * @generated + */ + public String getSummary() + { + return summary; + } + /** + * + * + * @generated + */ + public void setSummary(String newSummary) + { + summary = newSummary; + } + + /** + * + * + * @generated + */ + public String getAddress() + { + return address; + } + /** + * + * + * @generated + */ + public void setAddress(String newAddress) + { + address = newAddress; + } + + /** + * + * + * @generated + */ + public String getDate() + { + return date; + } + /** + * + * + * @generated + */ + public void setDate(String newDate) + { + date = newDate; + } + + /** + * + * + * @generated + */ + public String getSourceId() + { + return sourceId; + } + /** + * + * + * @generated + */ + public void setSourceId(String newSourceId) + { + sourceId = newSourceId; + } + + /** + * + * + * @generated + */ + public boolean isUnread() + { + return unread; + } + /** + * + * + * @generated + */ + public void setUnread(boolean newUnread) + { + unread = newUnread; + } + + /** + * + * + * @generated + */ + public String getId() + { + return id; + } + /** + * + * + * @generated + */ + public void setId(String newId) + { + id = newId; + } + + /** + * + * + * @generated + */ + @Override + public String toString() + { + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (Title: "); + result.append(title); + result.append(", Summary: "); + result.append(summary); + result.append(", Address: "); + result.append(address); + result.append(", Date: "); + result.append(date); + result.append(", SourceId: "); + result.append(sourceId); + result.append(", Unread: "); + result.append(unread); + result.append(", Id: "); + result.append(id); + result.append(')'); + return result.toString(); + } + +} //AlertTypeImpl diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java new file mode 100644 index 0000000000..e070e0b8f1 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.demos.aggregator; + +import java.text.DateFormat; + +import org.apache.abdera.Abdera; +import org.apache.abdera.factory.Factory; +import org.apache.abdera.model.Entry; +import org.apache.abdera.model.Feed; +import org.apache.tuscany.sca.binding.atom.collection.Collection; +import org.apache.tuscany.sca.binding.atom.collection.NotFoundException; +import org.apache.tuscany.sca.demos.aggregator.types.AlertType; +import org.apache.tuscany.sca.demos.aggregator.types.AlertsType; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * Read all new alerts from the specified sources + * + * @version $Rev$ $Date$ + */ +@Service(Collection.class) +public class AlertsFeedServiceImpl implements Collection { + + private AlertsService alerts; + + @Reference + public void setAlerts(AlertsService alerts) { + this.alerts = alerts; + } + + DateFormat dateFormatter = DateFormat.getDateTimeInstance(); + + /** + * Return the alerts as a feed. + * + * @return the structure containing alerts + */ + public org.apache.abdera.model.Feed getFeed() { + + // Create a new Feed + Factory factory = Abdera.getNewFactory(); + Feed feed = factory.newFeed(); + feed.setTitle("Apache Tuscany Feed Aggregator"); + feed.setSubtitle("A sample showing an SCA application to aggregate various types of feeds"); + feed.addAuthor("Apache Tuscany"); + feed.addLink("http://tuscany.apache.org"); + + // Aggregate entries from feed1 and feed2 + try { + AlertsType alerts = this.alerts.getAllNewAlerts(""); + + for( Object alertObject : alerts.getAlert() ){ + AlertType alert = ((AlertType)alertObject); + Entry entry = factory.newEntry(); + entry.setTitle(alert.getTitle()); + //entry.(alert.getSummary()); + entry.addLink(alert.getAddress()); + entry.setPublished(dateFormatter.parse(alert.getDate())); + + feed.addEntry(entry); + } + } catch(Exception ex) { + System.err.println("Exception " + ex.toString()); + } + + return feed; + } + + public Feed query(String queryString) { + return getFeed(); + } + + 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 { + } + +} diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsService.java b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsService.java new file mode 100644 index 0000000000..c4bf13ce7a --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsService.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.demos.aggregator; + +import org.apache.tuscany.sca.demos.aggregator.types.AlertsType; +import org.osoa.sca.annotations.Remotable; + +/** + * Retrieve and manage alerts + * + * @version $Rev$ $Date$ + */ +@Remotable +public interface AlertsService { + + /** + * Return a structure holding all of the new alerts that have been found + * + * @return the structure containing alerts + */ + public AlertsType getAllNewAlerts(String id); + +} diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsServiceImpl.java b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsServiceImpl.java new file mode 100644 index 0000000000..28e27a9978 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsServiceImpl.java @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.demos.aggregator; + +import java.text.DateFormat; +import java.util.Date; +import java.util.List; + +import org.apache.tuscany.sca.demos.aggregator.types.AlertType; +import org.apache.tuscany.sca.demos.aggregator.types.AlertsType; +import org.apache.tuscany.sca.demos.aggregator.types.ConfigType; +import org.apache.tuscany.sca.demos.aggregator.types.SourceType; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * Read all new alerts from the specified sources + * + * @version $Rev$ $Date$ + */ +@Service(AlertsService.class) +public class AlertsServiceImpl implements AlertsService { + + private RSSCheckerService rssChecker; + + private AlertsSourcesService alertsSources; + + @Reference + public void setRssChecker(RSSCheckerService rssChecker) { + this.rssChecker = rssChecker; + } + + @Reference + public void setAlertsSources(AlertsSourcesService alertsSources) { + this.alertsSources = alertsSources; + } + + DateFormat dateFormatter = DateFormat.getDateTimeInstance(); + + /** + * Return a structure holding all of the new alerts that have been found + * + * @return the structure containing alerts + */ + public AlertsType getAllNewAlerts(String id) + { + System.err.println("getAllNewAlerts(" + id + ")"); + + //TypesFactory factory = TypesFactory.INSTANCE; + //AlertsType returnAlerts = factory.createAlertsType(); + AlertsType returnAlerts = new AlertsTypeNonSDOImpl(); + List returnAlertList = returnAlerts.getAlert(); + + // get the date/time now so that we can update the + // alert source record so that next time we + // only get the latest alerts + Date now = new Date(); + String nowString = dateFormatter.format(now); + + try { + ConfigType alertSourceConfig = alertsSources.getAlertSources(id); + + for (Object source : alertSourceConfig.getSource()){ + SourceType sourceType = (SourceType)source; + + AlertsType alerts = null; + + if ( sourceType.getFeedType().equals("rss")){ + alerts = rssChecker.getNewAlerts(sourceType.getFeedAddress(), + sourceType.getLastChecked()); + } else { + + } + + // extend return list with any alerts we found + for( Object alert : alerts.getAlert() ){ + + // set the id on the alert so we know which source it + // came from + ((AlertType)alert).setSourceId(sourceType.getId()); + + // convert from SDO to POJO so that the + // JSONRPC binding will work. It can't currently + // handle SDOs + AlertType newAlert = new AlertTypeNonSDOImpl(); + + newAlert.setSourceId(((AlertType)alert).getSourceId()); + newAlert.setTitle(((AlertType)alert).getTitle()); + newAlert.setSummary(((AlertType)alert).getSummary()); + newAlert.setAddress(((AlertType)alert).getAddress()); + newAlert.setDate(((AlertType)alert).getDate()); + newAlert.setId(((AlertType)alert).getId()); + newAlert.setUnread(((AlertType)alert).isUnread()); + + returnAlertList.add(newAlert); + } + + // update the time last checked for this source + sourceType.setLastChecked(nowString); + //alertsSources.updateAlertSource(sourceType); + } + } catch(Exception ex) { + System.err.println("Exception " + ex.toString()); + } + + return returnAlerts ; + + } +} diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesService.java b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesService.java new file mode 100644 index 0000000000..7b943b1b45 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesService.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.demos.aggregator; + +import org.apache.tuscany.sca.demos.aggregator.types.ConfigType; +import org.apache.tuscany.sca.demos.aggregator.types.SourceType; +import org.osoa.sca.annotations.Remotable; + +/** + * Retrieve and manage alert sources + * + * @version $Rev$ $Date$ + */ +@Remotable +public interface AlertsSourcesService { + + /** + * Return all of the configured alert sources. + * + * @return the list of alert sources + */ + public ConfigType getAlertSources (String id); + + /** + * Return a single alert source. + * @param id not currently used + * @return the alert source + */ + public SourceType getAlertSource (String id); + + /** + * Update an alert source. + * + * @param updatedSource the alert source to update + */ + public void updateAlertSource (SourceType updatedSource); + + /** + * Add an alert source. + * + * @param newSource the alert source to add + */ + public String addAlertSource (SourceType newSource); + + /** + * Remove an alert source. + * + * @param oldSource the alert source to remove + */ + public void removeAlertSource (String id); + +} diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesServiceImpl.java b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesServiceImpl.java new file mode 100644 index 0000000000..ca2fc95b4a --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesServiceImpl.java @@ -0,0 +1,183 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.demos.aggregator; + +import java.io.InputStream; +import java.text.DateFormat; +import java.util.Date; + +import org.apache.tuscany.sca.demos.aggregator.types.ConfigType; +import org.apache.tuscany.sca.demos.aggregator.types.SourceType; +import org.apache.tuscany.sca.demos.aggregator.types.TypesFactory; +import org.apache.tuscany.sca.demos.aggregator.types.impl.SourceTypeImpl; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.impl.HelperProvider; + +/** + * Retrieve and manage alert sources + * + * @version $Rev$ $Date$ + */ +@Service(AlertsSourcesService.class) +@Scope("COMPOSITE") +public class AlertsSourcesServiceImpl implements AlertsSourcesService { + + ConfigType alertSources; + + /** + * Constructor reads the configuration to provide + * the initial list of alert sources + */ + public AlertsSourcesServiceImpl(){ + System.err.println("AlertsSourcesServiceImpl()"); + try { + // read the alerts config from an XML file + InputStream is = this.getClass().getClassLoader().getResourceAsStream("sources.xml"); + + if (is == null) { + throw new Exception("Can;t find sources.xml"); + } else { + HelperContext helperContext = HelperProvider.getDefaultContext(); + TypesFactory.INSTANCE.register(helperContext); + XMLDocument xmlDoc = helperContext.getXMLHelper().load(is); + alertSources = (ConfigType)xmlDoc.getRootObject(); + } + } catch (Exception ex) { + System.err.println("Exception " + ex.toString()); + } + } + + /** + * Return all of the configured alert sources. + * + * @return the list of alert sources + */ + public ConfigType getAlertSources (String id) + { + System.err.println("getAlertSources(" + id + ")"); + + // convert alert sources to POJOs so that + // the JSONRPC binding will work + ConfigTypeNonSDOImpl sources = new ConfigTypeNonSDOImpl(); + + for (Object source : alertSources.getSource()) { + SourceTypeNonSDOImpl newSource = new SourceTypeNonSDOImpl(); + newSource.setAddress(((SourceTypeImpl)source).getAddress()); + newSource.setFeedAddress(((SourceTypeImpl)source).getFeedAddress()); + newSource.setId(((SourceTypeImpl)source).getId()); + newSource.setLastChecked(((SourceTypeImpl)source).getLastChecked()); + newSource.setName(((SourceTypeImpl)source).getName()); + newSource.setFeedType(((SourceTypeImpl)source).getFeedType()); + sources.getSource().add(newSource); + } + + return sources; + } + + /** + * Return a single alert source. + * @param id the alert source id number + * @return the alert source + */ + public SourceType getAlertSource (String id) + { + System.err.println("getAlertSource(" + id + ")"); + SourceType alertSource = null; + + for (Object source : alertSources.getSource()) { + if ( ((SourceType)source).getId().equals(id)) { + alertSource = (SourceType)source; + } + } + return alertSource; + } + + /** + * Update an alert source. + * + * @param updatedSource the alert source to update + */ + public void updateAlertSource (SourceType updatedSource) + { + System.err.println("updateAlertSource()"); + + Object originalSource = null; + + for (Object source : alertSources.getSource()) { + if ( ((SourceType)source).getId().equals(updatedSource.getId())) { + originalSource = source; + break; + } + } + + if (originalSource != null){ + alertSources.getSource().add(updatedSource); + alertSources.getSource().remove(originalSource); + } + } + + /** + * Add an alert source. + * + * @param newSource the alert source to add + */ + public String addAlertSource (SourceType newSource) + { + System.err.println("addAlertSource()"); + // set the date to now less 2 hours so we + // get some alerts straight away + DateFormat dateFormatter = DateFormat.getDateTimeInstance(); + Date now = new Date(); + now.setHours(now.getHours()-2); + String nowString = dateFormatter.format(now); + newSource.setLastChecked(nowString); + alertSources.getSource().add(newSource); + return "Done"; + } + + /** + * Remove an alert source. + * + * @param oldSource the alert source to remove + */ + public void removeAlertSource (String id) + { + System.err.println("removeAlertSource()"); + + Object originalSource = null; + + for (Object source : alertSources.getSource()) { + if ( ((SourceType)source).getId().equals(id)) { + originalSource = source; + break; + } + } + + if (originalSource != null) { + alertSources.getSource().remove(originalSource); + } + + } + +} diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java new file mode 100644 index 0000000000..2962defb25 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.demos.aggregator; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.demos.aggregator.types.AlertsType; + +/** + * + * An implementation of the model object 'Alerts Type'. + * + *

+ * The following features are implemented: + *

+ *

+ * + * @generated + */ +public class AlertsTypeNonSDOImpl implements AlertsType +{ + private static final long serialVersionUID = -3784576466148158776L; + +/** + * The cached value of the '{@link #getAlert() Alert}' containment reference list. + * + * + * @see #getAlert() + * @generated + * @ordered + */ + + protected List alert = new ArrayList(); + + /** + * + * + * @generated + */ + public AlertsTypeNonSDOImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public List getAlert() + { + return alert; + } + +} //AlertsTypeImpl diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/ConfigTypeNonSDOImpl.java b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/ConfigTypeNonSDOImpl.java new file mode 100644 index 0000000000..75544294ce --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/ConfigTypeNonSDOImpl.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.demos.aggregator; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.demos.aggregator.types.ConfigType; + + +public class ConfigTypeNonSDOImpl implements ConfigType +{ + private static final long serialVersionUID = 2522843951360675364L; + + protected List source = new ArrayList(); + + /** + * + * + * @generated + */ + public ConfigTypeNonSDOImpl() + { + super(); + } + + + /** + * + * + * @generated + */ + public List getSource() + { + return source; + } + + +} //ConfigTypeImpl diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerService.java b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerService.java new file mode 100644 index 0000000000..2a5775e9a9 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerService.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.demos.aggregator; + +import org.apache.tuscany.sca.demos.aggregator.types.AlertsType; + +/** + * The interface for the rss checker service + */ +public interface RSSCheckerService { + + public AlertsType getNewAlerts(String rssaddress, String lastchecktimestamp); + +} diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerServiceImpl.java b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerServiceImpl.java new file mode 100644 index 0000000000..549abbf602 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerServiceImpl.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.demos.aggregator; + +import java.net.URL; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +import org.apache.tuscany.sca.demos.aggregator.types.AlertType; +import org.apache.tuscany.sca.demos.aggregator.types.AlertsType; +import org.apache.tuscany.sca.demos.aggregator.types.TypesFactory; + +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.io.SyndFeedInput; +import com.sun.syndication.io.XmlReader; + +/** + * The interface for the rss checker service + */ +public class RSSCheckerServiceImpl implements RSSCheckerService { + + public AlertsType getNewAlerts(String rssaddress, String lastchecktimestamp){ + // Create the list of alerts to return + TypesFactory factory = TypesFactory.INSTANCE; + AlertsType returnAlerts = factory.createAlertsType(); + List returnAlertList = returnAlerts.getAlert(); + + try { + // lastchecktimestamp comes from sources.xml configuration. + // That origin requires ISO 8601 date input (yyyy-MM-dd hh:mm:ss). + DateFormat configDateFormatter = new SimpleDateFormat( "yyyy-MM-dd hh:mm:ss"); + Date timestamp = configDateFormatter.parse(lastchecktimestamp); + // Turn feed dates into something we can process. + DateFormat feedDateFormatter = DateFormat.getDateTimeInstance(); + + // get the feed data from the supplied address + SyndFeedInput input = new SyndFeedInput(); + SyndFeed feed = input.build(new XmlReader(new URL(rssaddress))); + //System.out.println(feed); + + // check all the items to see if we have seen them before + List entries = feed.getEntries(); + for(Object entry: entries){ + SyndEntry syndEntry = (SyndEntry)entry; + + // System.err.println( "Entry pubdate=" + syndEntry.getPublishedDate() ); + if (syndEntry.getPublishedDate().after(timestamp)){ + AlertType newAlert = factory.createAlertType(); + + newAlert.setTitle(syndEntry.getTitle()); + // newAlert.setSummary(""); + newAlert.setSummary(""); + newAlert.setAddress(syndEntry.getLink()); + newAlert.setDate(feedDateFormatter.format(syndEntry.getPublishedDate())); + newAlert.setId(rssaddress); + newAlert.setUnread(true); + + returnAlertList.add(newAlert); + } + } + + } catch(Exception ex) { + ex.printStackTrace( System.err ); + System.err.println("Exception " + ex.toString()); + } + + return returnAlerts; + } + +} diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/SourceTypeNonSDOImpl.java b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/SourceTypeNonSDOImpl.java new file mode 100644 index 0000000000..10575bf0dc --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/SourceTypeNonSDOImpl.java @@ -0,0 +1,536 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.demos.aggregator; + +import org.apache.tuscany.sca.demos.aggregator.types.SourceType; + +import commonj.sdo.Sequence; + + +public class SourceTypeNonSDOImpl implements SourceType +{ + private static final long serialVersionUID = -4986294578888767793L; + + public final static int NAME = 0; + + public final static int ADDRESS = 1; + + public final static int LAST_CHECKED = 2; + + public final static int FEED_ADDRESS = 3; + + public final static int POP_SERVER = 4; + + public final static int POP_USERNAME = 5; + + public final static int POP_PASSWORD = 6; + + public final static int ANY = -1; + + public final static int ID = 7; + + public final static int TYPE = 8; + + public final static int SDO_PROPERTY_COUNT = 9; + + public final static int EXTENDED_PROPERTY_COUNT = -1; + + + /** + * The internal feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_NAME = 0; + + /** + * The internal feature id for the 'Address' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ADDRESS = 1; + + /** + * The internal feature id for the 'Last Checked' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_LAST_CHECKED = 2; + + /** + * The internal feature id for the 'Feed Address' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_FEED_ADDRESS = 3; + + /** + * The internal feature id for the 'Pop Server' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_POP_SERVER = 4; + + /** + * The internal feature id for the 'Pop Username' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_POP_USERNAME = 5; + + /** + * The internal feature id for the 'Pop Password' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_POP_PASSWORD = 6; + + /** + * The internal feature id for the 'Any' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ANY = 7; + + /** + * The internal feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ID = 8; + + /** + * The internal feature id for the 'Type' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_TYPE = 9; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 10; + + + + + /** + * The default value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_DEFAULT_; + + /** + * The default value of the '{@link #getAddress() Address}' attribute. + * + * + * @see #getAddress() + * @generated + * @ordered + */ + protected static final String ADDRESS_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getAddress() Address}' attribute. + * + * + * @see #getAddress() + * @generated + * @ordered + */ + protected String address = ADDRESS_DEFAULT_; + + /** + * The default value of the '{@link #getLastChecked() Last Checked}' attribute. + * + * + * @see #getLastChecked() + * @generated + * @ordered + */ + protected static final String LAST_CHECKED_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getLastChecked() Last Checked}' attribute. + * + * + * @see #getLastChecked() + * @generated + * @ordered + */ + protected String lastChecked = LAST_CHECKED_DEFAULT_; + + /** + * The default value of the '{@link #getFeedAddress() Feed Address}' attribute. + * + * + * @see #getFeedAddress() + * @generated + * @ordered + */ + protected static final String FEED_ADDRESS_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getFeedAddress() Feed Address}' attribute. + * + * + * @see #getFeedAddress() + * @generated + * @ordered + */ + protected String feedAddress = FEED_ADDRESS_DEFAULT_; + + /** + * The default value of the '{@link #getPopServer() Pop Server}' attribute. + * + * + * @see #getPopServer() + * @generated + * @ordered + */ + protected static final String POP_SERVER_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getPopServer() Pop Server}' attribute. + * + * + * @see #getPopServer() + * @generated + * @ordered + */ + protected String popServer = POP_SERVER_DEFAULT_; + + /** + * The default value of the '{@link #getPopUsername() Pop Username}' attribute. + * + * + * @see #getPopUsername() + * @generated + * @ordered + */ + protected static final String POP_USERNAME_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getPopUsername() Pop Username}' attribute. + * + * + * @see #getPopUsername() + * @generated + * @ordered + */ + protected String popUsername = POP_USERNAME_DEFAULT_; + + /** + * The default value of the '{@link #getPopPassword() Pop Password}' attribute. + * + * + * @see #getPopPassword() + * @generated + * @ordered + */ + protected static final String POP_PASSWORD_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getPopPassword() Pop Password}' attribute. + * + * + * @see #getPopPassword() + * @generated + * @ordered + */ + protected String popPassword = POP_PASSWORD_DEFAULT_; + + /** + * The cached value of the '{@link #getAny() Any}' attribute list. + * + * + * @see #getAny() + * @generated + * @ordered + */ + + protected Sequence any = null; + + /** + * The default value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected static final String ID_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected String id = ID_DEFAULT_; + + /** + * The default value of the '{@link #getFeedType() Feed Type}' attribute. + * + * + * @see #getFeedType() + * @generated + * @ordered + */ + protected static final String FEED_TYPE_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getFeedType() Feed Type}' attribute. + * + * + * @see #getFeedType() + * @generated + * @ordered + */ + protected String feedType = FEED_TYPE_DEFAULT_; + + + /** + * + * + * @generated + */ + public SourceTypeNonSDOImpl() + { + super(); + } + + + + /** + * + * + * @generated + */ + public String getName() + { + return name; + } + /** + * + * + * @generated + */ + public void setName(String newName) + { + name = newName; + } + + /** + * + * + * @generated + */ + public String getAddress() + { + return address; + } + /** + * + * + * @generated + */ + public void setAddress(String newAddress) + { + address = newAddress; + } + + /** + * + * + * @generated + */ + public String getLastChecked() + { + return lastChecked; + } + /** + * + * + * @generated + */ + public void setLastChecked(String newLastChecked) + { + lastChecked = newLastChecked; + } + + /** + * + * + * @generated + */ + public String getFeedAddress() + { + return feedAddress; + } + /** + * + * + * @generated + */ + public void setFeedAddress(String newFeedAddress) + { + feedAddress = newFeedAddress; + } + + /** + * + * + * @generated + */ + public String getPopServer() + { + return popServer; + } + /** + * + * + * @generated + */ + public void setPopServer(String newPopServer) + { + popServer = newPopServer; + } + + /** + * + * + * @generated + */ + public String getPopUsername() + { + return popUsername; + } + /** + * + * + * @generated + */ + public void setPopUsername(String newPopUsername) + { + popUsername = newPopUsername; + } + + /** + * + * + * @generated + */ + public String getPopPassword() + { + return popPassword; + } + /** + * + * + * @generated + */ + public void setPopPassword(String newPopPassword) + { + popPassword = newPopPassword; + } + + /** + * + * + * @generated + */ + public String getId() + { + return id; + } + /** + * + * + * @generated + */ + public void setId(String newId) + { + id = newId; + } + + /** + * + * + * @generated + */ + public String getFeedType() + { + return feedType; + } + /** + * + * + * @generated + */ + public void setFeedType(String newType) + { + feedType = newType; + } + + public Sequence getAny(){ + return null; + } + +} //SourceTypeImpl diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/Alerts.wsdl b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/Alerts.wsdl new file mode 100644 index 0000000000..8b376240c8 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/Alerts.wsdl @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/Alerts.xsd b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/Alerts.xsd new file mode 100644 index 0000000000..f0ec561ad8 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/Alerts.xsd @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/AlertsSources.wsdl b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/AlertsSources.wsdl new file mode 100644 index 0000000000..d5642a32d1 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/AlertsSources.wsdl @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/alerts-client.composite b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/alerts-client.composite new file mode 100644 index 0000000000..49f44f9da8 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/alerts-client.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/alerts.composite b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/alerts.composite new file mode 100644 index 0000000000..c359b275be --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/alerts.composite @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/sources.xml b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/sources.xml new file mode 100644 index 0000000000..e45250eddb --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/resources/sources.xml @@ -0,0 +1,34 @@ + + + + + + BBC News + http://news.bbc.co.uk/ + 2008-06-20 12:00:00 + http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml + + + Engadget + http://www.engadget.com + 2008-06-20 12:00:00 + http://www.engadget.com/rss.xml + + diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/AlertAggregator.html b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/AlertAggregator.html new file mode 100644 index 0000000000..8b472fd0fa --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/AlertAggregator.html @@ -0,0 +1,330 @@ + + + +Apache Tuscany Alert Aggregator Sample + + + + + + + + + + + + + + + +

Apache Tuscany Alert Aggregator Demo

+
+

Alert Sources:

+ +
Refreshing...
+

+

+

Refreshing...
+

Back to top

+
+

+

+ + + diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..09b7cce2b4 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..84f2ab693d --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,37 @@ + + + + + + org.apache.tuscany.sca + demo-alert-aggregator-webapp + 1.4 + war + + + + org.apache.axiom + org.apache.axis2 + org.apache.commons + org.jdom + + + diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..a81165e1b4 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + + + Apache Tuscany Alert Aggregator Demo + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + AlertAggregator.html + + + diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/pop.png b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/pop.png new file mode 100644 index 0000000000..1cf1df24a7 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/pop.png differ diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/rss.png b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/rss.png new file mode 100644 index 0000000000..b3c949d224 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/rss.png differ diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/service.smd b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/service.smd new file mode 100644 index 0000000000..3c6b6c9b12 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/service.smd @@ -0,0 +1 @@ +{"SMDVersion":".1","objectName":"AlertsService","serviceType":"JSON-RPC","serviceURL":"http://localhost:8085/sample-feed-aggregator/services/AlertsServiceJSONRPC","methods":[{"name":"getAllNewAlerts","parameters":[{"name":"param0","type":"STRING"}]}]} diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/sources.smd b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/sources.smd new file mode 100644 index 0000000000..b5f1824363 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/sources.smd @@ -0,0 +1 @@ +{"SMDVersion":".1","objectName":"AlertsSourcesService","serviceType":"JSON-RPC","serviceURL":"http://localhost:8081/sample-feed-aggregator/services/AlertsSourcesServiceJSONRPC","methods":[{"name":"getAlertSources","parameters":[{"name":"param0","type":"STRING"}]},{"name":"getAlertSource","parameters":[{"name":"param0","type":"STRING"}]},{"name":"updateAlertSource","parameters":[{"name":"param0","type":"STRING"}]},{"name":"addAlertSource","parameters":[{"name":"param0","type":"STRING"}]},{"name":"removeAlertSource","parameters":[{"name":"param0","type":"STRING"}]}]} diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/style.css b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/style.css new file mode 100644 index 0000000000..f5bbf23379 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/main/webapp/style.css @@ -0,0 +1,176 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +p,table,li,h1,h2,h3 +{ +font-family: verdana, arial, 'sans serif'; +} + +p, h1, h2, h3, table, li, hr +{ +margin-left: 10pt; +} + +table +{ +border-color: black; +border-collapse: separate; +border-spacing: 0px 1px; + +margin-right: 10pt; +margin-left: 10pt; +width: 800px; +} + +.sourceDetailsTable +{ +width: 600px; +} + +tr, td +{ +margin-left: 0pt; +margin-right: 0pt; +padding-left: 10pt; +font-size: 90%; +} + +p,li,th +{ +font-size: 90%; +margin-left: 10pt; +} + +pre +{ +margin-left: 10pt; +} + +body +{ +#ffffff; +} + +h1,h2,h3,hr +{ +color: firebrick; +} + +a:link {COLOR: firebrick;} +a:visited {COLOR: firebrick;} +a:active {COLOR: navy;} + +.link +{ +COLOR: firebrick; +text-decoration: underline; +} + +.clickable +{ +cursor: pointer +} + +.unread_title +{ +font-weight: bold; +} + +.read_title +{ +font-weight: normal; +} + +.summary +{ +color: DimGrey; +} + +.hidden +{ +display: none; +} + +.source_name +{ +width: 600px; +} + +.alert_text +{ +width: 600px; +} + +.alert_data +{ +margin-left: 10px; +width: 800px; +height: 800px; +} + +.source_0 +{ +background-color: LightGreen; +} + +.source_1 +{ +background-color: LightSkyBlue; +} + +.source_2 +{ +background-color: Khaki; +} + +.source_3 +{ +background-color: LightPink; +} + +.source_4 +{ +background-color: Orange; +} + +.source_5 +{ +background-color: LightCoral; +} + +.source_6 +{ +background-color: Orchid; +} + +.source_7 +{ +background-color: Peru; +} + +.source_8 +{ +background-color: SpringGreen; +} + +.source_9 +{ +background-color: LightGrey; +} + diff --git a/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/test/java/org/apache/tuscany/sca/demos/aggregator/AlertsIntegrationTest.java b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/test/java/org/apache/tuscany/sca/demos/aggregator/AlertsIntegrationTest.java new file mode 100644 index 0000000000..f0cb9ecfcb --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/alert-aggregator-webapp/src/test/java/org/apache/tuscany/sca/demos/aggregator/AlertsIntegrationTest.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.demos.aggregator; + +import java.io.ByteArrayInputStream; + +import junit.framework.Assert; + +import org.json.JSONObject; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.meterware.httpunit.PostMethodWebRequest; +import com.meterware.httpunit.WebConversation; +import com.meterware.httpunit.WebRequest; +import com.meterware.httpunit.WebResponse; + + +/** + */ +public class AlertsIntegrationTest { + //private static SCADomain scaDomain; + + @BeforeClass + public static void setUp() throws Exception { + //scaDomain = SCADomain.newInstance("alerts.composite"); + } + + /** + * Runs after each test method + */ + @AfterClass + public static void tearDown() { + //scaDomain.close(); + } + +/* Use this if you want to test locally without deploying to a web container + public void testWait() throws Exception { + System.out.println("Feed aggregator server started (press enter to shutdown)"); + System.in.read(); + System.out.println("Feed aggregator server stopped"); + } +*/ + + @Test + public void testGetAllNewAlerts() throws Exception { + JSONObject jsonRequest = new JSONObject("{\"params\":[\"sometext\"],\"method\":\"getAllNewAlerts\",\"id\":2}"); + JSONObject jsonResp = callService ("http://localhost:8085/demo-alert-aggregator-webapp/AlertsServiceJSONRPC", + jsonRequest); + Assert.assertNotNull(jsonResp); + } + + @Test + public void testAddAlertSources() throws Exception { + JSONObject jsonRequest = new JSONObject("{\"params\":[{\"name\":\"news\",\"id\":\"2\",\"address\":\"www.news.com\",\"feedAddress\":\"http://news.com.com/2547-1_3-0-20.xml\",\"feedType\":\"rss\",\"lastChecked\":\"lastChecked\",\"javaClass\":\"org.apache.tuscany.sca.demos.aggregator.types.impl.SourceTypeImpl\"}],\"method\":\"addAlertSource\",\"id\":2}"); + JSONObject jsonResp = callService ("http://localhost:8085/demo-alert-aggregator-webapp/AlertsSourcesServiceJSONRPC", + jsonRequest); + Assert.assertNotNull(jsonResp); + } + + @Test + public void testGetAlertSources() throws Exception { + JSONObject jsonRequest = new JSONObject("{\"params\":[\"sometext\"],\"method\":\"getAlertSources\",\"id\":2}"); + JSONObject jsonResp = callService ("http://localhost:8085/demo-alert-aggregator-webapp/AlertsSourcesServiceJSONRPC", + jsonRequest); + Assert.assertEquals("BBC News", jsonResp.getJSONObject("result").getJSONObject("source").optJSONArray("list").getJSONObject(0).getString("name")); + } + + public JSONObject callService(String url, JSONObject jsonRequest) throws Exception { + System.out.println("Request = " + jsonRequest.toString()); + WebConversation wc = new WebConversation(); + WebRequest request = new PostMethodWebRequest( url, + new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")),"application/json"); + WebResponse response = wc.getResource(request); + System.out.println("Response= " + response.getText()); + Assert.assertEquals(200, response.getResponseCode()); + return new JSONObject(response.getText()); + } +} diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-account/README b/sca-java-1.x/tags/1.4/demos/bigbank-account/README new file mode 100644 index 0000000000..5c0d850c5e --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/README @@ -0,0 +1,4 @@ +bigbank-account is part of a larger demo called bigbank. +Please see the Readme file under bigbank to understand how bigbank-account fits into the overall demo. + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-account/bigbank.png b/sca-java-1.x/tags/1.4/demos/bigbank-account/bigbank.png new file mode 100644 index 0000000000..985cc6bd05 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/bigbank-account/bigbank.png differ diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-account/bigbank.svg b/sca-java-1.x/tags/1.4/demos/bigbank-account/bigbank.svg new file mode 100644 index 0000000000..0650075d48 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/bigbank.svg @@ -0,0 +1,537 @@ + + + + + + + + + + image/svg+xml + + + + + + + + CompositeBigBank WebApp + + Component AccountJava + + + + Component AccountDataJava + binding.jsonrpc + binding.ws + binding.rmi + + + + CompositeStockQuote + + CompositeCalculator + + Component CalculatorJava + + + + Component AddJavascript + binding.rmi + + + Component SubtractRuby + + Component MultiplyPython + + Component DivideGroovy + + + + Component StockQuoteJava + + binding.ws + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-account/build-dojo.xml b/sca-java-1.x/tags/1.4/demos/bigbank-account/build-dojo.xml new file mode 100644 index 0000000000..0e029c6335 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/build-dojo.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-account/build.xml b/sca-java-1.x/tags/1.4/demos/bigbank-account/build.xml new file mode 100644 index 0000000000..9eb11f760d --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/build.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-account/pom.xml b/sca-java-1.x/tags/1.4/demos/bigbank-account/pom.xml new file mode 100644 index 0000000000..10759c3824 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/pom.xml @@ -0,0 +1,76 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-demos + 1.4 + ../pom.xml + + demo-bigbank-account + jar + Apache Tuscany SCA Demo BigBank Account + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-core-spi + 1.4 + + + + org.apache.tuscany.sca + tuscany-policy-security + 1.4 + + + + org.apache.ws.security + wss4j + 1.5.3 + + + + + demo-bigbank-account + + + org.apache.maven.plugins + maven-antrun-plugin + + + + ant + ant-trax + 1.6.5 + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountDetails.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountDetails.java new file mode 100644 index 0000000000..57c1adcba0 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/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$$ $$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.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountService.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountService.java new file mode 100644 index 0000000000..bf919525c4 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/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$$ $$Date$$ + */ +@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.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java new file mode 100644 index 0000000000..0ed4b1dd2e --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/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.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountDetails.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountDetails.java new file mode 100644 index 0000000000..cc9023da60 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountDetails.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 bigbank.account.savings; + +import java.io.Serializable; + +/** + * @version $$Rev$$ $$Date: 2007-04-09 12:03:34 -0700 (Mon, 09 Apr + * 2007) $$ + */ + +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.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountService.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountService.java new file mode 100644 index 0000000000..5bf6e6d26b --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountService.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.account.savings; + +import org.osoa.sca.annotations.Remotable; + +/** + * @version $$Rev$$ $$Date$$ + */ +@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.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java new file mode 100644 index 0000000000..1f4f02ea6d --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.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.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.4/demos/bigbank-account/src/main/java/bigbank/account/security/AccountsDataPasswordCallbackHandler.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/AccountsDataPasswordCallbackHandler.java new file mode 100644 index 0000000000..579b4ee64b --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/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.4/demos/bigbank-account/src/main/java/bigbank/account/security/BigbankCheckingsAcl.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/BigbankCheckingsAcl.java new file mode 100644 index 0000000000..5c64e11d10 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/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$ $Date$ + */ +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.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthImplementationPolicyProvider.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthImplementationPolicyProvider.java new file mode 100644 index 0000000000..c98dcacbf3 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/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$ $Date$ + */ +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.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicy.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicy.java new file mode 100644 index 0000000000..121ee9a3f8 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/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$ $Date$ + */ +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.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyInterceptor.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyInterceptor.java new file mode 100644 index 0000000000..1d565f7ca1 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyInterceptor.java @@ -0,0 +1,79 @@ +package bigbank.account.security; + +import java.security.Principal; +import java.util.logging.ConsoleHandler; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.xml.namespace.QName; + +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.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyProviderFactory.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthPolicyProviderFactory.java new file mode 100644 index 0000000000..5fecef691e --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/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$ $Date$ + */ +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.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyHandler.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyHandler.java new file mode 100644 index 0000000000..6667a4ba53 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/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$ $Date$ + */ +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.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyProcessor.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/security/CheckingsDeptAuthorizationPolicyProcessor.java new file mode 100644 index 0000000000..da1b6e1d06 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/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.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountDetails.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountDetails.java new file mode 100644 index 0000000000..1473436000 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountDetails.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.stock; + +/** + * @version $$Rev$$ $$Date: 2007-04-09 12:03:34 -0700 (Mon, 09 Apr + * 2007) $$ + */ + +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.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountService.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountService.java new file mode 100644 index 0000000000..fcbf8a4831 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountService.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.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.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java new file mode 100644 index 0000000000..28101a1986 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/java/bigbank/account/stock/StockAccountServiceImpl.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 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.4/demos/bigbank-account/src/main/resources/CheckingsAccount.composite b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/CheckingsAccount.composite new file mode 100644 index 0000000000..cc76e30a75 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/CheckingsAccount.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..c050b550a5 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/tags/1.4/demos/bigbank-account/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.4/demos/bigbank-account/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.4/demos/bigbank-account/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler b/sca-java-1.x/tags/1.4/demos/bigbank-account/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.4/demos/bigbank-account/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.4/demos/bigbank-account/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sca-java-1.x/tags/1.4/demos/bigbank-account/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.4/demos/bigbank-account/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.4/demos/bigbank-account/src/main/resources/SavingsAccount.composite b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/SavingsAccount.composite new file mode 100644 index 0000000000..696b96d6e6 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/SavingsAccount.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/StockAccount.composite b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/StockAccount.composite new file mode 100644 index 0000000000..62c0b63003 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/StockAccount.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/definitions.xml b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/definitions.xml new file mode 100644 index 0000000000..31a8798f8b --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/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.4/demos/bigbank-account/src/main/resources/web/AccountJSON.html b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/web/AccountJSON.html new file mode 100644 index 0000000000..1609bf4b43 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/web/AccountJSON.html @@ -0,0 +1,92 @@ + + + +Tuscany JSON-RPC BigBank Client + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Tuscany JSON-RPC BigBank Client
+

This example uses the Dojo + Toolkit to create a JavaScript object accountService for + the service at http://localhost:8080/AccountJSONService using Dojo's + RPC classes and providing them with http://localhost:8080/AccountJSONService?smd + for Simple Method Description + (SMD) input.

+

It then creates a Dojo button that will envoke the getAccountReport + method of the accountService object.

+
RequestResponse

+ +
+
+
None Yet.
+
+
Dojo Debug:
+
+ + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/web/style.css b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/web/style.css new file mode 100644 index 0000000000..1071583264 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/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.4/demos/bigbank-account/src/main/resources/wsdl/AccountService.wsdl b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/wsdl/AccountService.wsdl new file mode 100644 index 0000000000..ac4d987a57 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-account/src/main/resources/wsdl/AccountService.wsdl @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-calculator/README b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/README new file mode 100644 index 0000000000..e8ff28fc0f --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/README @@ -0,0 +1,2 @@ +bigbank-calculator is part of a larger demo called bigbank. +Please see the Readme file under bigbank to understand how bigbank-calculator fits into the overall demo. diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-calculator/build.xml b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/build.xml new file mode 100644 index 0000000000..e6b4e49b7d --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/build.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-calculator/pom.xml b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/pom.xml new file mode 100644 index 0000000000..4e0298e369 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-demos + 1.4 + ../pom.xml + + demo-bigbank-calculator + Apache Tuscany SCA Demo BigBank Calculator + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-script + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-rmi-runtime + 1.4 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/AddService.java b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..4eeb30a9c2 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/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 calculator; + +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..c89043276e --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/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.4/demos/bigbank-calculator/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..ed7bee0f4e --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/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 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.4/demos/bigbank-calculator/src/main/java/calculator/DivideService.java b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..131c5a8014 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/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 calculator; + +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..a917896aeb --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/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 calculator; + +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/SubtractService.java b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..e328f024ea --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/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 calculator; + +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/demo/CalculatorServer.java b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/demo/CalculatorServer.java new file mode 100644 index 0000000000..b1861daafc --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/java/calculator/demo/CalculatorServer.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator.demo; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * @version $Rev$ $Date$ + */ +public class CalculatorServer { + + public static void main(String[] args) throws Exception { + + System.out.println("Starting the Sample SCA Calculator..."); + + SCADomain domain = SCADomain.newInstance("Calculator.composite"); + + System.out.println("Press Enter to Exit..."); + System.in.read(); + + domain.close(); + + System.out.println("Bye"); + System.exit(0); + } + +} diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/resources/Calculator.composite b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..851813d31f --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/resources/Calculator.composite @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/resources/calculator/AddServiceImpl.js b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/resources/calculator/AddServiceImpl.js new file mode 100644 index 0000000000..1d4d221364 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/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.4/demos/bigbank-calculator/src/main/resources/calculator/DivideServiceImpl.groovy b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/resources/calculator/DivideServiceImpl.groovy new file mode 100644 index 0000000000..c31c1e8fd6 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/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.4/demos/bigbank-calculator/src/main/resources/calculator/MultiplyServiceImpl.py b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/resources/calculator/MultiplyServiceImpl.py new file mode 100644 index 0000000000..dd56af0ad8 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/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.4/demos/bigbank-calculator/src/main/resources/calculator/SubtractServiceImpl.rb b/sca-java-1.x/tags/1.4/demos/bigbank-calculator/src/main/resources/calculator/SubtractServiceImpl.rb new file mode 100644 index 0000000000..08fa310f46 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/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.4/demos/bigbank-stockquote/README b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/README new file mode 100644 index 0000000000..2ea98d020c --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/README @@ -0,0 +1,4 @@ +bigbank-stockquote is a part of a larger demo called bigbank. +Please see the Readme file under bigbank to understand how bigbank-stockquote fits into the overall demo. + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/build.xml b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/build.xml new file mode 100644 index 0000000000..e1565c7e01 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/build.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/pom.xml b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/pom.xml new file mode 100644 index 0000000000..e60411d0f4 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/pom.xml @@ -0,0 +1,85 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-demos + 1.4 + ../pom.xml + + demo-bigbank-stockquote + Apache Tuscany SCA Demo BigBank StockQuote + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4 + + + + org.apache.ws.security + wss4j + 1.5.3 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.4 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/java/stockquote/PasswordCallbackHandler.java b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/java/stockquote/PasswordCallbackHandler.java new file mode 100644 index 0000000000..2d7821171d --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/java/stockquote/PasswordCallbackHandler.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 stockquote; + +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 PasswordCallbackHandler 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("*** Getting password for user ...." + pwcb.getIdentifer() + " & " + pwcb.getKey()); + if ( pwcb.getUsage() == WSPasswordCallback.SIGNATURE ) { + System.out.println(" Usage is SIGNATURE ... "); + pwcb.setPassword("sqservice"); + } + } + } + +} diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/java/stockquote/StockQuoteImpl.java b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/java/stockquote/StockQuoteImpl.java new file mode 100644 index 0000000000..2a0801f9b8 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/java/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 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.4/demos/bigbank-stockquote/src/main/java/stockquote/StockQuoteService.java b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/java/stockquote/StockQuoteService.java new file mode 100644 index 0000000000..9d128657eb --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/java/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 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.4/demos/bigbank-stockquote/src/main/java/stockquote/demo/StockQuoteServer.java b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/java/stockquote/demo/StockQuoteServer.java new file mode 100644 index 0000000000..04ed762602 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/java/stockquote/demo/StockQuoteServer.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 stockquote.demo; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This server program shows how to bootstrap SCA from a simple J2SE program + * and start it which activates the StockQuote Web service endpoint. + */ +public class StockQuoteServer { + + public static void main(String[] args) throws Exception { + + System.out.println("Starting the Sample SCA StockQuote Service..."); + + SCADomain domain = SCADomain.newInstance("StockQuote.composite"); + + System.out.println("Press Enter to Exit..."); + System.in.read(); + + domain.close(); + System.out.println("Bye"); + } + +} diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/StockQuote.composite b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/StockQuote.composite new file mode 100644 index 0000000000..aaad92c861 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/StockQuote.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/definitions.xml b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/definitions.xml new file mode 100644 index 0000000000..7e1f51304e --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/definitions.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + Timestamp Signature + security.properties + + + + + Timestamp Signature + sqservice + security.properties + stockquote.PasswordCallbackHandler + DirectReference + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/security.properties b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/security.properties new file mode 100644 index 0000000000..a5b889c269 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/security.properties @@ -0,0 +1,20 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- +org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin +org.apache.ws.security.crypto.merlin.keystore.type=jks +org.apache.ws.security.crypto.merlin.keystore.password=sqkeystore +org.apache.ws.security.crypto.merlin.file=stockQuote.jks diff --git a/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/stockQuote.jks b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/stockQuote.jks new file mode 100644 index 0000000000..d53d32c4ef Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/bigbank-stockquote/src/main/resources/stockQuote.jks differ diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/README b/sca-java-1.x/tags/1.4/demos/bigbank/README new file mode 100644 index 0000000000..1e52c65b70 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/README @@ -0,0 +1,114 @@ +BigBank Demo +============ + +This application is made of 3 modules that represent the different aspects +of a fictitious banking application. Please see bigbank.png in the bigbank-account directory for a diagram of this demo. + +To run the bigbank-account demo you need to first run bigbank-calculator and bigbank-stockquote composites. This will bring up Tuscany runtime and load the two applications and make them available as services. Bigbank-account is dependent on these services. + +This demo uses ant. This is just one way of running this demo. + +Start Bigbank-calculator composite +---------------------------------- + +Bigbank-calculator is a calculator application which handles add, subtract, multiply and divide operations. Each of these operations is implemented in a different language, including JavaScript, groovy, Ruby and Python. + +To run the bigbank-calculator composite and make it available as a service for this demo do the following: + +cd bigbank-calculator +ant run + +.. Leave the server running + +Note that 'ant compile' needs to be done the first time you run this demo out of the binary distribution. No need to do 'ant compile' from there on. + +Start Bigbank-stockquote +------------------------ + +A very simple web services based stock quote application which returns random +stock quotes on request. Please note that the stockquote service is not live and is implemented instead to allow for this application to always run without dependency on the availability of a webservice. + +cd bigbank-stockquote +ant run + +.. Leave the server running + +Note that 'ant compile' needs to be done the first time you run this demo out of the binary distribution. No need to do 'ant compile' from there on. + +Start Bigbank +------------- +The BigBank comprises of two subsystems that are built from two distinct contributions coming from ... +1) bigbank + This contains all artifacts that make up the bigbank application. This is the application that the + end user interacts with + +2) bigbank-account + This contains all artifacts that deal with the account management within the bigbank. The services + offered by the bigbank-account module are used by the bigbank. The end user never gets to directly + interact with bigbank account + +Besides the bigbank-account the bigbank composite application calls into bigbank-stockquote and +bigbank-calculator services. + +Start bigbank-account in the following way: + + cd bigbank + ant run + + .. Leave the server running + +Bigbank and the SCA Policies +---------------------------- +The Bigbank demo uses the Tuscany PolicyFramework to enforce security in the following ways: + +Authentication +-------------- + The bigbank-account subsystem enforces authentication as a required security characteristic for + all interactions with its CheckingAccountService. Hence the 'bigbank' application which is a client + to this service authenticates itself for every interaction with the CheckingAccountService. The interaction + between the bigbank and the CheckingAccountService is over the ws binding. + +Integrity +--------- + All interactions of the bigbank application with the StockQuoteService are guarded with message integrity. + These interactions use the ws binding. + +Authorization +------------- + Within the bigbank-account subsystem the CheckingAccountService implementation enforces authorization on + its operations. This is an instance of a custom policy enforcement i.e. the CheckingAccountService + component's implementation has defined its own customized way of authorizing access to its services. + +Demonstrated features +--------------------- +This demo is to illustrate the following : - +- composition of an application using artifacts belonging to multiple contributions (here two) +- usage of sca policies in composite definitions with specific emphasis on enabling security + + +Run the demo +------------- +The front end of this demo application is a web app which users Json/RPC to communicate with the backend for retrieving account information. + +To try the app out point you browser at: + +http://localhost:8085/AccountJSON.html + +This should display an interface with a single button that goes and retrieves +a single set of account details exercising services across the three running +SCA applications. + +If you press on getAccountReport, you'll see a response posted, +but the detail of the data will be displayed in the console where you started bigbank. Among other +things you will note messages that confirm the enforecement of AUTHENTICATION, AUTHORIZATION and +SIGNING of messages exchaged. + +On the console where you have started the StockQuote Service you should again be able to see messages +that confirm the signing of messages exchanged. + +Stop the demo +------------- +Go to each of the corresponding command line screens and hit 'enter'. +This will stop each of the applications. + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/bigbank.png b/sca-java-1.x/tags/1.4/demos/bigbank/bigbank.png new file mode 100644 index 0000000000..985cc6bd05 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/bigbank/bigbank.png differ diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/bigbank.svg b/sca-java-1.x/tags/1.4/demos/bigbank/bigbank.svg new file mode 100644 index 0000000000..30aa0eab6d --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/bigbank.svg @@ -0,0 +1,537 @@ + + + + + + + + + + image/svg+xml + + + + + + + + CompositeBigBank WebApp + + Component AccountJava + + + + Component AccountDataJava + binding.jsonrpc + binding.ws + binding.rmi + + + + CompositeStockQuote + + CompositeCalculator + + Component CalculatorJava + + + + Component AddJavascript + binding.rmi + + + Component SubtractRuby + + Component MultiplyPython + + Component DivideGroovy + + + + Component StockQuoteJava + + binding.ws + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/build-dojo.xml b/sca-java-1.x/tags/1.4/demos/bigbank/build-dojo.xml new file mode 100644 index 0000000000..9d282c2dd2 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/build-dojo.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/build.xml b/sca-java-1.x/tags/1.4/demos/bigbank/build.xml new file mode 100644 index 0000000000..81fb704d4d --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/build.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/pom.xml b/sca-java-1.x/tags/1.4/demos/bigbank/pom.xml new file mode 100644 index 0000000000..05a5b3121e --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/pom.xml @@ -0,0 +1,201 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-demos + 1.4 + ../pom.xml + + demo-bigbank + jar + Apache Tuscany SCA Demo BigBank + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4 + + + + org.apache.tuscany.sca + tuscany-data-api + 1.4 + + + + org.apache.ws.security + wss4j + 1.5.3 + + + + org.apache.tuscany.sca + demo-bigbank-account + 1.4 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-rss-rome + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-rmi-runtime + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-resource-runtime + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.4 + runtime + + + + junit + junit + 4.5 + test + + + + + + demo-bigbank + + + org.apache.maven.plugins + maven-antrun-plugin + + + + ant + ant-trax + 1.6.5 + + + + + + install-dojo + validate + + run + + + + + + + + + + + copy-dojo-files + generate-resources + + run + + + + + + + + + + + + clean-dojo-files + clean + + run + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/account/AccountService.java b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/account/AccountService.java new file mode 100644 index 0000000000..2cb8027874 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/account/AccountService.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; + +import org.osoa.sca.annotations.Remotable; + +/** + * @version $$Rev$$ $$Date$$ + */ + +@Remotable +public interface AccountService { + + public double getAccountReport(String customerID); + +} diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/account/AccountServiceImpl.java b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/account/AccountServiceImpl.java new file mode 100644 index 0000000000..4f0e3879dc --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/account/AccountServiceImpl.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 bigbank.account; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import stockquote.StockQuoteService; +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 calculator.CalculatorService; + +/** + * @version $$Rev$$ $$Date$$ + */ + +@Service(AccountService.class) +public class AccountServiceImpl implements AccountService { + + @Reference + protected SavingsAccountService savingsAcService; + + @Reference + protected CheckingAccountService checkingAcService; + + @Reference + protected StockAccountService stockAcService; + + @Reference + protected StockQuoteService stockQuoteService; + + @Reference + protected CalculatorService calculatorService; + + @Property + protected String currency; + + public double getAccountReport(String customerID) { + + // Get the checking, savings and stock accounts from the AccountData + // service component + CheckingAccountDetails checking = null; + try { + checking = checkingAcService.getAccountDetails(customerID); + System.out.println("Checking account: " + checking); + + SavingsAccountDetails savings = savingsAcService.getAccountDetails(customerID); + System.out.println("Savings account: " + savings); + + StockAccountDetails stock = stockAcService.getAccountDetails(customerID); + System.out.println("Stock account: " + stock); + + // 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(); + + // Calculate the total balance of all accounts and return it + double balance = checking.getBalance() + savings.getBalance() + stockValue; + + return balance; + } catch ( Throwable e ) { + e.printStackTrace(); + return 0; + } + } +} diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java new file mode 100644 index 0000000000..13d79a9c33 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.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.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; + +/** + * @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 + double balance = accountService.getAccountReport(id); + String report = Double.toString(balance); + + 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.4/demos/bigbank/src/main/java/bigbank/client/BigBankClient.java b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/client/BigBankClient.java new file mode 100644 index 0000000000..a7fa5ecc22 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/client/BigBankClient.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.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 domain = SCADomain.newInstance("BigBank.composite"); + + AccountService accountService = domain.getService(AccountService.class, "AccountServiceComponent"); + + String customerID = "1234"; + + System.out.println("Calling account service for customer: " + customerID); + System.out.println(); + double balance = accountService.getAccountReport(customerID); + + System.out.println(); + System.out.println("Balance: " + balance); + + domain.close(); + } + +} diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/demo/BigBankServer.java b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/demo/BigBankServer.java new file mode 100644 index 0000000000..05360e07a5 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/demo/BigBankServer.java @@ -0,0 +1,130 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package bigbank.demo; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.service.ContributionService; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain; + +import bigbank.account.savings.SavingsAccountService; + + + +/** + * 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 BigBank server..."); + ClassLoader cl = BigBankServer.class.getClassLoader(); + EmbeddedSCADomain domain = new EmbeddedSCADomain(cl, "http://localhost"); + + //Start the domain + domain.start(); + + // Contribute the SCA contribution + ContributionService contributionService = domain.getContributionService(); + + URL javaContribURL = getContributionURL(SavingsAccountService.class); + Contribution bigbankAcContribution = contributionService.contribute("http://bigbank-account", javaContribURL, false); + for (Composite deployable : bigbankAcContribution.getDeployables()) { + domain.getDomainComposite().getIncludes().add(deployable); + domain.buildComposite(deployable); + } + + URL bigbankContribUrl = getContributionURL(BigBankServer.class); + Contribution bigbankContribution = contributionService.contribute("http://bigbank", bigbankContribUrl, false); + for (Composite deployable : bigbankContribution.getDeployables()) { + domain.getDomainComposite().getIncludes().add(deployable); + domain.buildComposite(deployable); + } + + + //Start Components from composite + for (Composite deployable : bigbankAcContribution.getDeployables()) { + domain.getCompositeActivator().activate(deployable); + domain.getCompositeActivator().start(deployable); + } + + for (Composite deployable : bigbankContribution.getDeployables()) { + domain.getCompositeActivator().activate(deployable); + domain.getCompositeActivator().start(deployable); + } + + if (timeout < 0) { + System.out.println("Press Enter to Exit..."); + System.in.read(); + } else { + Thread.sleep(timeout); + } + + contributionService.remove("http://bigbank-account"); + contributionService.remove("http://bigbank"); + + // Stop Components from composite + for (Composite deployable : bigbankContribution.getDeployables()) { + domain.getCompositeActivator().stop(deployable); + domain.getCompositeActivator().deactivate(deployable); + } + + domain.stop(); + + domain.close(); + + + /*SCADomain domain = SCADomain.newInstance("BigBank.composite"); + + if (timeout < 0) { + System.out.println("Press Enter to Exit..."); + System.in.read(); + } else { + Thread.sleep(timeout); + } + + domain.close();*/ + + System.out.println("Bye"); + } + + private static URL getContributionURL(Class cls) throws MalformedURLException { + String flag = "/" + cls.getName().replace('.', '/') + ".class"; + URL url = cls.getResource(flag); + String root = url.toExternalForm(); + root = root.substring(0, root.length() - flag.length() + 1); + if (root.startsWith("jar:") && root.endsWith("!/")) { + root = root.substring(4, root.length() - 2); + } + url = new URL(root); + return url; + } + +} diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java new file mode 100644 index 0000000000..6d3b547939 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.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 BigbankPasswordCallbackHandler implements CallbackHandler { + + public void handle(Callback[] callbacks) throws IOException, + UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; + //System.out.println("*** Getting password for user ...." + pwcb.getIdentifer() + " & " + pwcb.getKey()); + if ( pwcb.getUsage() == WSPasswordCallback.SIGNATURE ) { + System.out.println("*** Calling BIG-BANK Passwd Handler for SIGNING...." ); + pwcb.setPassword("bbservice"); + } else if ( pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN ) { + if ( pwcb.getIdentifer().equals("bbaservice")) { + System.out.println("*** Calling BIG-BANK Passwd Handler for setting AUTHENTICATION password...." ); + pwcb.setPassword("bbaservice"); + } + } + } + } + +} diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..c89043276e --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/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.4/demos/bigbank/src/main/java/stockquote/StockQuoteService.java b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/stockquote/StockQuoteService.java new file mode 100644 index 0000000000..749b8ee2f4 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/java/stockquote/StockQuoteService.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 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.4/demos/bigbank/src/main/resources/BigBank.composite b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/BigBank.composite new file mode 100644 index 0000000000..11591308b4 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/BigBank.composite @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + EURO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..dc72a36cd4 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/bigbank.jks b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/bigbank.jks new file mode 100644 index 0000000000..e6294d85f7 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/bigbank.jks differ diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/definitions.xml b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/definitions.xml new file mode 100644 index 0000000000..8654151d82 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/definitions.xml @@ -0,0 +1,64 @@ + + + + + + + + + + Timestamp Signature + security.properties + + + + + Timestamp Signature + bbservice + security.properties + bigbank.security.BigbankPasswordCallbackHandler + DirectReference + + + + + + + + + + UsernameToken + bbaservice + bigbank.security.BigbankPasswordCallbackHandler + PasswordText + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/security.properties b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/security.properties new file mode 100644 index 0000000000..d1b489acbb --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/security.properties @@ -0,0 +1,20 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- +org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin +org.apache.ws.security.crypto.merlin.keystore.type=jks +org.apache.ws.security.crypto.merlin.keystore.password=bbakeystore +org.apache.ws.security.crypto.merlin.file=bigbank.jks diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/web/AccountJSON.html b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/web/AccountJSON.html new file mode 100644 index 0000000000..9f4368443f --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/web/AccountJSON.html @@ -0,0 +1,92 @@ + + + +Tuscany JSON-RPC BigBank Client + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Tuscany JSON-RPC BigBank Client
+

This example uses the Dojo + Toolkit to create a JavaScript object accountService for + the service at http://localhost:8080/AccountJSONService using Dojo's + RPC classes and providing them with http://localhost:8080/AccountJSONService?smd + for Simple Method Description + (SMD) input.

+

It then creates a Dojo button that will envoke the getAccountReport + method of the accountService object.

+
RequestResponse

+ +
+
+
None Yet.
+
+
Dojo Debug:
+
+ + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/web/style.css b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/web/style.css new file mode 100644 index 0000000000..1071583264 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/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.4/demos/bigbank/src/main/resources/wsdl/AccountService.wsdl b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/wsdl/AccountService.wsdl new file mode 100644 index 0000000000..ac4d987a57 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/src/main/resources/wsdl/AccountService.wsdl @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/bigbank/src/test/java/test/BigBankTestCase.java b/sca-java-1.x/tags/1.4/demos/bigbank/src/test/java/test/BigBankTestCase.java new file mode 100644 index 0000000000..3b7c5ef2ad --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/bigbank/src/test/java/test/BigBankTestCase.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 test; + +import junit.framework.TestCase; + +import bigbank.demo.BigBankServer; + +/** + * @version $Rev$ $Date$ + */ +public class BigBankTestCase extends TestCase { + + public void testServer() throws Exception { + BigBankServer.main(new String[] {"1000"}); + } +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/README b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/README new file mode 100644 index 0000000000..b785802920 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/README @@ -0,0 +1,6 @@ +Mortgage Loan Approval Demo +=========================== +Please refer to the README under mortgage-loanapproval for information on how to run this demo. + +Mortgage-creditcheck is part of a larger demo that is explained there. + diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/build.xml b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/build.xml new file mode 100644 index 0000000000..f30df0a8c5 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/build.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/pom.xml b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/pom.xml new file mode 100644 index 0000000000..8a09d2930b --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/pom.xml @@ -0,0 +1,75 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-demos + 1.4 + ../pom.xml + + demo-mortgage-creditcheck + jar + Apache Tuscany SCA Demo Mortgage Credit Check + A sample Mortgage application made of several SCA components wired together. + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.4 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + + diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheck.java b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheck.java new file mode 100644 index 0000000000..ec95a60227 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheck.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 credit; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface CreditCheck { + int getCreditScore(String ssn); +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheckImpl.java b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheckImpl.java new file mode 100644 index 0000000000..f19e8a1250 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheckImpl.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 credit; + +import org.osoa.sca.annotations.Service; + +/** + * An implementation of the CreditReportService service + */ +@Service(CreditCheck.class) +public class CreditCheckImpl implements CreditCheck { + + public int getCreditScore(String ssn) { + int score = (int)(700 + (Math.random() - 0.5) * 100); + System.out.println("Credit score for " + ssn + ": " + score); + return score; + } +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheckServer.java b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheckServer.java new file mode 100644 index 0000000000..870ea1941d --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/java/credit/CreditCheckServer.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 credit; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * @version $Rev$ $Date$ + */ +public class CreditCheckServer { + public static void main(String[] args) throws Exception { + + System.out.println("Starting the CreditCheck Service..."); + + SCADomain domain = SCADomain.newInstance("http://localhost", "/", "CreditCheck.composite"); + + System.out.println("Press Enter to Exit..."); + System.in.read(); + + domain.close(); + System.out.println("Bye"); + } +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/resources/CreditCheck.composite b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/resources/CreditCheck.composite new file mode 100644 index 0000000000..5c828f5a39 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/resources/CreditCheck.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/resources/wsdl/credit.wsdl b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/resources/wsdl/credit.wsdl new file mode 100644 index 0000000000..9c2acc96d3 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/resources/wsdl/credit.wsdl @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..3e9e4539bd --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/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.4/demos/mortgage-creditcheck/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..d7b2e32dd1 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-creditcheck/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,37 @@ + + + + + + + Apache Tuscany Credit Check Demo + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/README b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/README new file mode 100644 index 0000000000..dbf3829a20 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/README @@ -0,0 +1,60 @@ +Mortgage Loan Approval Demo +=========================== + +This demo was used as an example in the java developer journal article: http://jdj.sys-con.com/read/325183.htm. + +The demo consists of two modules: + +mortgage-loanapproval: provides the business logic for loan approval. +mortgage-creditcheck: handles credit check requests. This is a java component exposed as a webservice running on the embedded Tomcat. + +Please check mortgage_assembly.png file that is located in this directory for a high level view of the demo. + +Here is what happens when you run the demo. A loan approval request for customer with id 111-222-3333 +gets initiated when mortgage-loanapproval application is run. Depending on what the 'imaginary' credit + status of this person is, the loan gets approved or diapproved. + +You would need two command windows to run mortgage loan approval composite. The order in which the +applications are run is important. Run mortgage-creditcheck first since mortgage-loanapproval is dependent on +it's service. + +In the first command window +--------------------------- +1) go to mortgage-creditcheck directory +2) ant compile +3) ant run +You should see the following displayed: +Buildfile: build.xml + +run: + [java] Starting the CreditCheck Service... + [java] 14-Jan-2008 14:14:20 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:8085/CreditCheckServiceC +omponent + [java] Press Enter to Exit... + +In the second command window +---------------------------- +1) go to mortgage-loanapproval directory +2) ant compile +3) ant run + +If the loan is approved, you will see the following displayed in the command screen where +mortgage-loanapproval is run: + +Buildfile: build.xml +run: + [java] Interest rate for a 30-year loan of $200000.0 in CA: 6.5% + [java] Approved: John Smith[111-22-3333] + +If the loan is disapproved, you will see the following displayed in the command screen where +mortgage-loanapproval is run: + +Buildfile: build.xml +run: + [java] Credit score for 111-22-3333: 708 + [java] Interest rate for a 30-year loan of $200000.0 in CA: 6.5% + [java] Debt/Income ratio 0.2528272093971861 is too high. + [java] Rejected: John Smith[111-22-3333] + diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/build.xml b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/build.xml new file mode 100644 index 0000000000..40b94f34b8 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/build.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/credit_composite.jpg b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/credit_composite.jpg new file mode 100644 index 0000000000..e28ed63cfb Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/credit_composite.jpg differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/credit_composite.png b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/credit_composite.png new file mode 100644 index 0000000000..0bfce0078d Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/credit_composite.png differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/loan_approval.jpg b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/loan_approval.jpg new file mode 100644 index 0000000000..3f00557c7f Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/loan_approval.jpg differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/loan_approval.png b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/loan_approval.png new file mode 100644 index 0000000000..9d5f829fe5 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/loan_approval.png differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly0.jpg b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly0.jpg new file mode 100644 index 0000000000..515b6ecde7 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly0.jpg differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly0.png b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly0.png new file mode 100644 index 0000000000..4b815a4b82 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly0.png differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly1.jpg b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly1.jpg new file mode 100644 index 0000000000..01a7c55a14 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly1.jpg differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly1.png b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly1.png new file mode 100644 index 0000000000..07422c4f45 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly1.png differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly2.jpg b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly2.jpg new file mode 100644 index 0000000000..992c048684 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly2.jpg differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly2.png b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly2.png new file mode 100644 index 0000000000..4667956ed0 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_assembly2.png differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_composite.jpg b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_composite.jpg new file mode 100644 index 0000000000..5021f6a317 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_composite.jpg differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_composite.png b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_composite.png new file mode 100644 index 0000000000..1398c50ded Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_composite.png differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_diagrams.doc b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_diagrams.doc new file mode 100644 index 0000000000..32a0b72907 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_diagrams.doc differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package1.jpg b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package1.jpg new file mode 100644 index 0000000000..e91c5f1bbd Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package1.jpg differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package1.png b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package1.png new file mode 100644 index 0000000000..db304a4c28 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package1.png differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package2.jpg b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package2.jpg new file mode 100644 index 0000000000..e8c2865e4a Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package2.jpg differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package2.png b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package2.png new file mode 100644 index 0000000000..502e538e94 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_package2.png differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_scenario.jpg b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_scenario.jpg new file mode 100644 index 0000000000..fccf2e35c3 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_scenario.jpg differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_scenario.png b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_scenario.png new file mode 100644 index 0000000000..b8f42ad318 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/doc/mortgage_scenario.png differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/mortgage_assembly.png b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/mortgage_assembly.png new file mode 100644 index 0000000000..4667956ed0 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/mortgage_assembly.png differ diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/pom.xml b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/pom.xml new file mode 100644 index 0000000000..b815000cf8 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-demos + 1.4 + ../pom.xml + + demo-mortgage-loanapproval + jar + Apache Tuscany SCA Demo Mortgage Loan Approval + A sample Mortgage application made of several SCA components wired together. + + + 1.4 + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4 + runtime + + + org.apache.tuscany.sca + tuscany-implementation-script + 1.4 + runtime + + + + + + install + ${artifactId} + + + org.apache.maven.plugins + maven-jar-plugin + + + + mortgage.MortgageClient + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheck.java b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheck.java new file mode 100644 index 0000000000..c5787b7819 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheck.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 mortgage; + +import org.osoa.sca.annotations.Remotable; + +/** + * CreditCheck interface + */ +@Remotable +public interface CreditCheck { + int getCreditScore(String ssn); +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheckImpl.java b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheckImpl.java new file mode 100644 index 0000000000..dc803d9688 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheckImpl.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 mortgage; + +import org.osoa.sca.annotations.Service; + +/** + * A pojo implementation of the CreditCheck service + */ +@Service(CreditCheck.class) +public class CreditCheckImpl implements CreditCheck { + + public int getCreditScore(String ssn) { + int score = (int)(700 + (Math.random() - 0.5) * 100); + System.out.println("Credit score for " + ssn + ": " + score); + return score; + } +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/Customer.java b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/Customer.java new file mode 100644 index 0000000000..66a486d516 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/Customer.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package mortgage; + +/** + * A simple Customer object + */ +public class Customer { + private String ssn; + private String firstName; + private String lastName; + private double monthlyIncome; + private String state; + + public double getMonthlyIncome() { + return monthlyIncome; + } + + public void setMonthlyIncome(double monthlyIncome) { + this.monthlyIncome = monthlyIncome; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getSsn() { + return ssn; + } + + public void setSsn(String ssn) { + this.ssn = ssn; + } + + @Override + public String toString() { + return firstName + " " + lastName + "[" + ssn + "]"; + } +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuote.java b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuote.java new file mode 100644 index 0000000000..b5bafeb204 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuote.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +public interface InterestRateQuote { + public float getRate(String state, double loanAmount, int termInYears); +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuoteImpl.java b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuoteImpl.java new file mode 100644 index 0000000000..8c642667f1 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuoteImpl.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 mortgage; + +import org.osoa.sca.annotations.Service; + +@Service(InterestRateQuote.class) +public class InterestRateQuoteImpl implements InterestRateQuote { + public float getRate(String state, double loanAmount, int termInYears) { + float rate = 6.0f; + if (termInYears == 5) { + rate = 5.5f; + } else { + rate = 6.5f; + } + System.out.println("Interest rate for a " + termInYears + + "-year loan of $" + + loanAmount + + " in " + + state + + ": " + + rate + + "%"); + return rate; + } +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApproval.java b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApproval.java new file mode 100644 index 0000000000..dcdad18496 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApproval.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 mortgage; + +/** + * Loan Approval interface + */ +public interface LoanApproval { + public boolean approve(Customer customer, double loanAmount, int years); +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApprovalImpl.java b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApprovalImpl.java new file mode 100644 index 0000000000..40bfdc4a1d --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApprovalImpl.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 mortgage; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * An implementation of the LoanApproval service. + */ +@Service(LoanApproval.class) +// Service declaration +public class LoanApprovalImpl implements LoanApproval { + private CreditCheck[] creditCheck; + private MortgageCalculator mortgageCalculator; + private InterestRateQuote interestRateQuote; + + // Reference declaration using a protected or public field + @Reference + public RiskAssessment riskAssessment; + + private int minimumCreditScore = 650; + + // Property declaration using a setter method + @Property(name = "minimumCreditScore") + public void setMinimumCreditScore(int minimumCreditScore) { + this.minimumCreditScore = minimumCreditScore; + } + + // Reference declaration using a setter method + @Reference + public void setCreditCheck(CreditCheck[] creditCheck) { + this.creditCheck = creditCheck; + } + + @Reference + public void setInterestRateQuote(InterestRateQuote interestRateQuote) { + this.interestRateQuote = interestRateQuote; + } + + @Reference + public void setMortgageCalculator(MortgageCalculator mortgageCalculator) { + this.mortgageCalculator = mortgageCalculator; + } + + public boolean approve(Customer customer, double loanAmount, int years) { + int score = 0; + for (int i = 0; i < creditCheck.length; i++) { + score += creditCheck[i].getCreditScore(customer.getSsn()); + } + if (score != 0) { + score = score / creditCheck.length; + } + if (score < minimumCreditScore) { + System.err.println("Credit score " + score + " is below the minimum " + minimumCreditScore + "."); + return false; + } + float rate = interestRateQuote.getRate(customer.getState(), loanAmount, years); + double monthlyPayment = mortgageCalculator.getMonthlyPayment(loanAmount, years, rate); + double ratio = monthlyPayment / customer.getMonthlyIncome(); + boolean approved = riskAssessment.assess(score, ratio); + if (!approved) { + System.err.println("Debt/Income ratio " + ratio + " is too high."); + } + return approved; + } +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculator.java b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculator.java new file mode 100644 index 0000000000..cacd8694de --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculator.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 mortgage; + +import org.osoa.sca.annotations.Remotable; + +/** + * The Mortgage Calculator service interface. + */ +@Remotable +public interface MortgageCalculator { + public double getMonthlyPayment(double principal, int years, float interestRate); +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculatorImpl.java b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculatorImpl.java new file mode 100644 index 0000000000..015f1bae98 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculatorImpl.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 mortgage; + +import org.osoa.sca.annotations.Service; + +/** + * An implementation of the Calculator service. + */ +@Service(MortgageCalculator.class) +public class MortgageCalculatorImpl implements MortgageCalculator { + + public double getMonthlyPayment(double principal, int years, float interestRate) { + double monthlyRate = interestRate / 12.0 / 100.0; + double p = Math.pow(1 + monthlyRate, years * 12); + double q = p / (p - 1); + double monthlyPayment = principal * monthlyRate * q; + System.out.println("Monthly payment for a " + years + "-year loan of $" + principal + ": " + monthlyPayment); + return monthlyPayment; + } + +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageClient.java b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageClient.java new file mode 100644 index 0000000000..d69f0a1163 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageClient.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 mortgage; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This client program to invoke the Mortgage LoanApproval service + */ +public class MortgageClient { + public static void main(String[] args) throws Exception { + + SCADomain domain = SCADomain.newInstance("Mortgage1.composite"); + LoanApproval loanApplication = domain.getService(LoanApproval.class, "LoanApprovalComponent"); + + // Create the customer + Customer customer = new Customer(); + customer.setSsn("111-22-3333"); + customer.setFirstName("John"); + customer.setLastName("Smith"); + customer.setMonthlyIncome(5000.0d); + customer.setState("CA"); + + // Invoke the service + boolean result = loanApplication.approve(customer, 200000d, 30); + System.out.println((result ? "Approved: " : "Rejected: ") + customer); + } +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessment.java b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessment.java new file mode 100644 index 0000000000..23c9589e85 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessment.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 mortgage; + +/** + * Risk Assessment interface + */ +public interface RiskAssessment { + public boolean assess(int creditScore, double ratio); +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessmentImpl.java b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessmentImpl.java new file mode 100644 index 0000000000..c2116366ec --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessmentImpl.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 mortgage; + +import org.osoa.sca.annotations.Service; + +/** + * A pojo implementation of RiskAssessment service + */ +@Service(RiskAssessment.class) +public class RiskAssessmentImpl implements RiskAssessment { + public boolean assess(int creditScore, double ratio) { + if (creditScore >= 750) { + return ratio < 0.35; + } else if (creditScore >= 700) { + return ratio < 0.30; + } else { + return ratio < 0.25; + } + } +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/Mortgage.composite b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/Mortgage.composite new file mode 100644 index 0000000000..d1128b9907 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/Mortgage.composite @@ -0,0 +1,48 @@ + + + + + + + 600 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/Mortgage1.composite b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/Mortgage1.composite new file mode 100644 index 0000000000..4cad6c7223 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/Mortgage1.composite @@ -0,0 +1,57 @@ + + + + + + + 600 + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.componentType b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.componentType new file mode 100644 index 0000000000..bf7b10e0f7 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.componentType @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.js b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.js new file mode 100644 index 0000000000..b25af1d039 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.js @@ -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. + */ +function getMonthlyPayment(principal, years, interestRate) { + var monthlyRate = interestRate / 12.0 / 100.0; + var p = Math.pow(1 + monthlyRate, years * 12); + var q = p / (p - 1); + var monthlyPayment = principal * monthlyRate * q; + return monthlyPayment; +} diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/wsdl/credit.wsdl b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/wsdl/credit.wsdl new file mode 100644 index 0000000000..9c2acc96d3 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/main/resources/wsdl/credit.wsdl @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/test/java/mortgage/MortgageClientTestCase.java b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/test/java/mortgage/MortgageClientTestCase.java new file mode 100644 index 0000000000..285cc72515 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/mortgage-loanapproval/src/test/java/mortgage/MortgageClientTestCase.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 mortgage; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This shows how to test the Calculator service component. + */ +public class MortgageClientTestCase extends TestCase { + private SCADomain domain; + private LoanApproval loanApproval; + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("Mortgage.composite"); + loanApproval = domain.getService(LoanApproval.class, "LoanApprovalComponent"); + } + + @Override + protected void tearDown() throws Exception { + if (domain != null) { + domain.close(); + } + } + + public void testApprove() throws Exception { + Customer customer = new Customer(); + customer.setSsn("111-22-3333"); + customer.setFirstName("John"); + customer.setLastName("Smith"); + customer.setMonthlyIncome(5000.0d); + customer.setState("CA"); + + boolean approved = loanApproval.approve(customer, 200000d, 30); + System.out.println((approved ? "Approved: " : "Rejected: ") + customer); + } +} diff --git a/sca-java-1.x/tags/1.4/demos/pom.xml b/sca-java-1.x/tags/1.4/demos/pom.xml new file mode 100644 index 0000000000..f252982703 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/pom.xml @@ -0,0 +1,52 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4 + ../pom.xml + + tuscany-demos + pom + Apache Tuscany SCA Demos + + + + default + + true + + + alert-aggregator-webapp + bigbank + bigbank-account + bigbank-calculator + bigbank-stockquote + mortgage-creditcheck + mortgage-loanapproval + xml-bigbank + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/README b/sca-java-1.x/tags/1.4/demos/xml-bigbank/README new file mode 100644 index 0000000000..3bdeeca60a --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/README @@ -0,0 +1,46 @@ +XML BigBank Demo +================ + +This demo showcases the integration with XML technolgies in the service assembly. + +Note: The live stock quote web service is not always running. Sometimes empty response is returned and the stock value is 0. + +To run the demo, type "ant run" and it will produce the following output. + +Buildfile: build.xml + +init: + [get] Getting: http://www.swanandmokashi.com/HomePage/WebServices/StockQuotes.asmx?WSDL + [get] To: C:\Apache\tuscany-sca-1.0.1-incubating\demos\xml-bigbank\src\main\resources\wsdl\StockQuotes.wsdl + [get] local file date : Tue Nov 06 15:50:37 PST 2007 + [get] . + [get] last modified = Wed Dec 31 16:00:00 PST 1969 - using current time instead + [mkdir] Created dir: C:\Apache\tuscany-sca-1.0.1-incubating\demos\xml-bigbank\target\classes + +compile: + [javac] Compiling 11 source files to C:\Apache\tuscany-sca-1.0.1-incubating\demos\xml-bigbank\target\classes + [copy] Copying 6 files to C:\Apache\tuscany-sca-1.0.1-incubating\demos\xml-bigbank\target\classes + [jar] Building jar: C:\Apache\tuscany-sca-1.0.1-incubating\demos\xml-bigbank\target\demo-xml-bigbank.jar + +run: + [java] Nov 6, 2007 3:52:28 PM org.apache.axis2.deployment.DeploymentEngine loadFromClassPath + [java] INFO: Module validation failed: The system is attempting to engage a module that is not available: rampart + [java] Retrieving exchange rate... + [java] Nov 6, 2007 3:52:29 PM org.apache.tuscany.sca.binding.feed.provider.RSSBindingInvoker invoke + [java] INFO: >>> RSSBindingInvoker (rss_2.0) http://ansuz.sooke.bc.ca/rippy/exchange/?M=R&B=USD&F=CAD,CNY,EUR&T=F&S=O&I=S + [java] Exchange rate: USD 1.0=EUR 0.68705 + [java] Loading account data... + [java] Getting stock quote... + [java] Nov 6, 2007 3:52:30 PM org.apache.commons.httpclient.HttpMethodBase readResponse + [java] INFO: Discarding unexpected response: HTTP/1.1 100 Continue + [java] Calculating total value... + [java] Checking Balance: xs:double: 1000 + [java] Saving Blance: xs:double: 20000 + [java] Stock Value: xs:integer: 0 + [java] Total Value [1]: xs:double: 21000 + [java] Total Value=USD 21000.0 + [java] EUR: 14428.050000000001 + +BUILD SUCCESSFUL +Total time: 7 seconds + diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/build.xml b/sca-java-1.x/tags/1.4/demos/xml-bigbank/build.xml new file mode 100644 index 0000000000..1d5266db1d --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/build.xml @@ -0,0 +1,63 @@ + + +]> + + + &buildDependency; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/pom.xml b/sca-java-1.x/tags/1.4/demos/xml-bigbank/pom.xml new file mode 100644 index 0000000000..8ee7eb844e --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/pom.xml @@ -0,0 +1,115 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-demos + 1.4 + ../pom.xml + + demo-xml-bigbank + jar + Apache Tuscany SCA Demo XML BigBank + Apache Tuscany SCA XML BigBank Demo + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.4 + compile + + + + org.apache.tuscany.sca + tuscany-binding-rss-rome + 1.4 + compile + + + + org.apache.tuscany.sca + tuscany-databinding-saxon + 1.4 + runtime + + + + + org.apache.tuscany.sca + tuscany-implementation-xquery + 1.4 + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.4 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4 + + + + bigbank.BigBankClient + true + + + generate + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountData.java b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountData.java new file mode 100644 index 0000000000..c3ae8d0912 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountData.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; + +import java.io.IOException; + +import javax.xml.stream.XMLStreamReader; + +/** + * @version $Rev$ $Date$ + */ +public interface AccountData { + /** + * Get the StAX stream that represent the accounts data + * @return The StAX stream containign the accounts + * @throws IOException + */ + XMLStreamReader getAccounts() throws IOException; +} diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountDataImpl.java b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountDataImpl.java new file mode 100644 index 0000000000..1c0c612987 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountDataImpl.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; + +import java.io.IOException; +import java.net.URL; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamReader; + +import org.osoa.sca.annotations.Service; + +/** + * @version $Rev$ $Date$ + */ +@Service(AccountData.class) +public class AccountDataImpl implements AccountData { + private XMLInputFactory factory = XMLInputFactory.newInstance(); + + public XMLStreamReader getAccounts() throws IOException { + URL doc = getClass().getResource("/accounts.xml"); + XMLStreamReader reader = null; + try { + reader = factory.createXMLStreamReader(doc.openStream()); + } catch (Exception e) { + e.printStackTrace(); + } + return reader; + } + +} diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountService.java b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountService.java new file mode 100644 index 0000000000..4c72384e7b --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountService.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; + + +/** + * @version $Rev$ $Date$ + */ +public interface AccountService { + /** + * Get the total value of all accounts owned by the customer + * @return The total value + */ + double getTotalValue(); +} diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java new file mode 100644 index 0000000000..00fce39462 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.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 bigbank; + +import java.io.StringReader; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamReader; + +import org.apache.axiom.om.OMElement; +import org.osoa.sca.ServiceRuntimeException; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * @version $Rev$ $Date$ + */ +@Service(AccountService.class) +public class AccountServiceImpl implements AccountService { + private static final String STOCK_QUOTE_REQUEST = + "IBM"; + + private XMLInputFactory factory = XMLInputFactory.newInstance(); + + @Reference + protected ExchangeRate exchangeRate; + + @Reference + protected StockQuote stockQuote; + + @Reference + protected AccountData accountData; + + @Reference + protected StockValue stockValue; + + @Property + protected String currency; + + public double getTotalValue() { + try { + double rate = exchangeRate.getExchangeRate(currency); + + System.out.println("Loading account data..."); + XMLStreamReader accounts = accountData.getAccounts(); + + System.out.println("Getting stock quote..."); + XMLStreamReader request = factory.createXMLStreamReader(new StringReader(STOCK_QUOTE_REQUEST)); + + OMElement quotes = stockQuote.GetQuote(request); + + String xml = quotes.getText(); + System.out.println(xml); + XMLStreamReader qts = factory.createXMLStreamReader(new StringReader(xml)); + System.out.println("Calculating total value..."); + double value = stockValue.calculate(qts, accounts); + + System.out.println("Total Value=USD " + value); + + return value * rate; + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } + } + +} diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/BigBankClient.java b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/BigBankClient.java new file mode 100644 index 0000000000..a7703787fb --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/BigBankClient.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; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This client program to invoke the Account service + */ +public class BigBankClient { + + public static void main(String[] args) throws Exception { + + SCADomain domain = SCADomain.newInstance("BigBank.composite"); + AccountService accountService = domain.getService(AccountService.class, "AccountService"); + + System.out.println("EUR: " + accountService.getTotalValue()); + } +} diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/BigBankServer.java b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/BigBankServer.java new file mode 100644 index 0000000000..f5f1ca90b6 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/BigBankServer.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 bigbank; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * @version $Rev$ $Date$ + */ +public class BigBankServer { + public static void main(String[] args) throws Exception { + + System.out.println("Starting the BigBank Service..."); + + SCADomain domain = SCADomain.newInstance("http://localhost", "/", "BigBank.composite"); + + System.out.println("Press Enter to Exit..."); + System.in.read(); + + domain.close(); + System.out.println("Bye"); + } +} diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/CurrencyExchange.java b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/CurrencyExchange.java new file mode 100644 index 0000000000..bb8ff85f45 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/CurrencyExchange.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; + +import org.osoa.sca.annotations.Remotable; + +import com.sun.syndication.feed.synd.SyndFeed; + +/** + * @version $Rev$ $Date$ + */ +@Remotable +public interface CurrencyExchange { + /** + * Get the currency exchange rates as a RSS feed + * @return + */ + SyndFeed getRates(); +} diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/ExchangeRate.java b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/ExchangeRate.java new file mode 100644 index 0000000000..358e5e19a2 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/ExchangeRate.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; + +/** + * @version $Rev$ $Date$ + */ +public interface ExchangeRate { + /** + * Look up the exchange rate of a currency against USD + * @param currency The currency + * @return The exchange rate + */ + double getExchangeRate(String currency); +} diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/ExchangeRateImpl.java b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/ExchangeRateImpl.java new file mode 100644 index 0000000000..fcb3707cfe --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/ExchangeRateImpl.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 bigbank; + +import java.io.ByteArrayInputStream; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathFactory; + +import org.osoa.sca.ServiceRuntimeException; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; +import org.w3c.dom.Document; +import org.w3c.dom.Node; + +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndFeed; + +/** + * @version $Rev$ $Date$ + */ +@Service(ExchangeRate.class) +public class ExchangeRateImpl { + @Reference + protected CurrencyExchange exchangeRate; + + private final DocumentBuilder builder; + + public ExchangeRateImpl() { + try { + builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + } catch (ParserConfigurationException e) { + throw new IllegalArgumentException(e); + } + } + + /** + * Retrieve the live currency exchange rate from a live feed and extract the data for a given + * currecy using XPath + * @param currency The currency + * @return The exchange rate + */ + public double getExchangeRate(String currency) { + try { + System.out.println("Retrieving exchange rate..."); + SyndFeed feed = exchangeRate.getRates(); + SyndEntry entry = (SyndEntry)feed.getEntries().get(0); + String rateTable = entry.getDescription().getValue(); + + Document doc = builder.parse(new ByteArrayInputStream(rateTable.getBytes())); + Node node = doc.getDocumentElement(); + XPath path = XPathFactory.newInstance().newXPath(); + XPathExpression exp = path.compile("/TABLE/TR[TD[1]='" + currency.toUpperCase() + "']/TD[2]"); + Node rateNode = (Node)exp.evaluate(node, XPathConstants.NODE); + double rate = Double.valueOf(rateNode.getTextContent().trim()); + System.out.println("Exchange rate: USD 1.0=" + currency + " " + rate); + return rate; + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } + } +} diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/StockQuote.java b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/StockQuote.java new file mode 100644 index 0000000000..26753a9e9e --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/StockQuote.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; + +import javax.xml.stream.XMLStreamReader; + +import org.apache.axiom.om.OMElement; +import org.osoa.sca.annotations.Remotable; + +/** + * @version $Rev$ $Date$ + */ +@Remotable +public interface StockQuote { + /** + * Invoke the stock quote web service to get the live quotes + * @param input The StAX stream of the request + * @return The StAX stream of the response + */ + public OMElement GetQuote(XMLStreamReader input); +} diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/StockValue.java b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/StockValue.java new file mode 100644 index 0000000000..c300103398 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/java/bigbank/StockValue.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; + +import javax.xml.stream.XMLStreamReader; + +import org.osoa.sca.annotations.Remotable; + +/** + * @version $Rev$ $Date$ + */ +@Remotable +public interface StockValue { + /** + * Join the quotes and accounts document to calculate the value + * @param quotes The quotes XML document + * @param accounts The accounts XML document + * @return The value + */ + double calculate(XMLStreamReader quotes, XMLStreamReader accounts); +} diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/BigBank.composite b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/BigBank.composite new file mode 100644 index 0000000000..8afde4bf80 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/BigBank.composite @@ -0,0 +1,51 @@ + + + + + + + + + + EUR + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/accounts.xml b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/accounts.xml new file mode 100644 index 0000000000..52ffd41fa7 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/accounts.xml @@ -0,0 +1,29 @@ + + + + John + Smith + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/customer.xsd b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/customer.xsd new file mode 100644 index 0000000000..b22efb74c4 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/customer.xsd @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/stock.xq b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/stock.xq new file mode 100644 index 0000000000..03c19e457d --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/stock.xq @@ -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. +:) +declare namespace q="http://www.webserviceX.NET/"; +declare namespace c="http://example.com/customer"; +declare namespace stock="scaservice:java/bigbank.StockValue"; +(: declare namespace currency="scaproperty:java/java.lang.String"; :) + +declare function stock:calculate($quoteDoc, $accountDoc) as xs:double { + let $checking := + trace( + sum( + for $a in $accountDoc/c:customer/c:accounts/c:checking + return $a/@balance + ), "Checking Balance") + + let $saving := + trace( + sum( + for $a in $accountDoc/c:customer/c:accounts/c:saving + return $a/@balance + ), "Saving Blance") + + let $value := + trace( + sum( + for $quote in $quoteDoc/StockQuotes/Stock, + $account in $accountDoc/c:customer/c:accounts/c:stock + where string($quote/Symbol) = string($account/@symbol) + return + trace(number($quote/Last),"Stock Price") * trace(number($account/@quantity), "Quantity") + ), "Stock Value") + return trace($checking + $saving + $value, "Total Value") +}; + + + diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/wsdl/StockQuotes.wsdl b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/wsdl/StockQuotes.wsdl new file mode 100644 index 0000000000..8411e22ff7 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/src/main/resources/wsdl/StockQuotes.wsdl @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/xml-bigbank.png b/sca-java-1.x/tags/1.4/demos/xml-bigbank/xml-bigbank.png new file mode 100644 index 0000000000..0743a413a3 Binary files /dev/null and b/sca-java-1.x/tags/1.4/demos/xml-bigbank/xml-bigbank.png differ diff --git a/sca-java-1.x/tags/1.4/demos/xml-bigbank/xml-bigbank.svg b/sca-java-1.x/tags/1.4/demos/xml-bigbank/xml-bigbank.svg new file mode 100644 index 0000000000..c7acc03324 --- /dev/null +++ b/sca-java-1.x/tags/1.4/demos/xml-bigbank/xml-bigbank.svg @@ -0,0 +1,447 @@ + + + + + + + + + + image/svg+xml + + + + + + + + BigBank + AccountData(Local file orDatabase) + + StockValue (XQuery) + + + + + + + + + + + + + + WS XML Feed(rss) + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + AccountService (Java) + + + ExchangeRate (Java) + + StockQuote(Live WebService) CurrencyExchangeRate (Live RSS Feed) + + + + -- cgit v1.2.3