From 0f72626e59d77f0365c1e6bbb9420f6693ffc67d Mon Sep 17 00:00:00 2001 From: lresende Date: Sat, 21 Nov 2009 07:55:01 +0000 Subject: Moving 1.x tags git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@882848 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/sampleapps/bigbank/account/LICENSE.txt | 202 +++++++++ .../java/sampleapps/bigbank/account/README.txt | 35 ++ .../java/sampleapps/bigbank/account/build.xml | 99 +++++ .../java/sampleapps/bigbank/account/pom.xml | 125 ++++++ .../java/sampleapps/bigbank/account/readme.htm | 20 + .../services/account/AccountServiceImpl.java | 260 ++++++++++++ .../services/accountdata/AccountDataService.java | 77 ++++ .../accountdata/AccountDataServiceDASImpl.java | 397 ++++++++++++++++++ .../accountdata/AccountDataServiceImpl.java | 99 +++++ .../account/services/accountdb/AccountDBInit.java | 452 +++++++++++++++++++++ .../account/services/stockquote/StockQuote.java | 223 ++++++++++ .../services/stockquote/StockQuoteService.java | 29 ++ .../services/stockquote/StockQuoteServiceImpl.java | 66 +++ .../StockQuoteWebservicexServiceImpl.java | 150 +++++++ .../src/main/resources/DasAccountConfiguration.xml | 65 +++ .../WebservicexService_stockquote.fragment | 32 ++ .../src/main/resources/mock_stockquote.fragment | 27 ++ .../account/src/main/resources/sca.fragment | 27 ++ .../bigbank/account/src/main/resources/sca.module | 55 +++ .../account/src/main/resources/sca.subsystem | 22 + .../src/main/resources/wsdl/AccountService.wsdl | 392 ++++++++++++++++++ .../resources/wsdl/stockquotes.webservicex.wsdl | 133 ++++++ .../account/src/main/webapp/WEB-INF/web.xml | 28 ++ .../java/bigbank/account/client/AccountClient.java | 57 +++ .../java/sampleapps/bigbank/build.xml | 28 ++ .../java/sampleapps/bigbank/docs/Show.Image.html | 22 + .../java/sampleapps/bigbank/docs/accountfiles.png | Bin 0 -> 12297 bytes .../sampleapps/bigbank/docs/modualoverview.png | Bin 0 -> 6074 bytes .../sampleapps/bigbank/docs/webclientfiles.png | Bin 0 -> 16568 bytes .../java/sampleapps/bigbank/pom.xml | 34 ++ .../java/sampleapps/bigbank/readme.htm | 94 +++++ .../java/sampleapps/bigbank/webclient/LICENSE.txt | 202 +++++++++ .../java/sampleapps/bigbank/webclient/README.txt | 35 ++ .../java/sampleapps/bigbank/webclient/build.xml | 85 ++++ .../java/sampleapps/bigbank/webclient/pom.xml | 95 +++++ .../java/sampleapps/bigbank/webclient/readme.htm | 20 + .../account/AccountServiceComponentImpl.java | 106 +++++ .../services/profile/AccountLoginServiceImpl.java | 50 +++ .../webclient/services/profile/LoginService.java | 30 ++ .../webclient/services/profile/ProfileService.java | 36 ++ .../services/profile/ProfileServiceImpl.java | 67 +++ .../services/profile/SimpleLoginServiceImpl.java | 49 +++ .../webclient/tags/account/AccountStatusTag.java | 125 ++++++ .../webclient/tags/account/StockStatusTag.java | 79 ++++ .../webclient/tags/sca/LoginBarrierTag.java | 97 +++++ .../bigbank/webclient/tags/sca/ServiceTag.java | 98 +++++ .../java/bigbank/webclient/ui/FormServlet.java | 156 +++++++ .../java/bigbank/webclient/ui/LoginServlet.java | 91 +++++ .../webclient/src/main/resources/sca.module | 51 +++ .../webclient/src/main/resources/sca.subsystem | 27 ++ .../src/main/resources/wsdl/AccountService.wsdl | 392 ++++++++++++++++++ .../webclient/src/main/webapp/CustomerProfile.jsp | 97 +++++ .../src/main/webapp/WEB-INF/bigbank-tags.tld | 91 +++++ .../webclient/src/main/webapp/WEB-INF/web.xml | 44 ++ .../src/main/webapp/accountTransaction.jsp | 47 +++ .../bigbank/webclient/src/main/webapp/login.html | 42 ++ .../webclient/src/main/webapp/purchaseStock.jsp | 56 +++ .../webclient/src/main/webapp/stockSale.jsp | 53 +++ .../bigbank/webclient/src/main/webapp/summary.jsp | 136 +++++++ .../webclient/client/TestAccountService.java | 52 +++ .../bigbank/webclient/client/TestLoginService.java | 50 +++ .../java-M1-20060518/java/sampleapps/build.xml | 26 ++ .../tags/java-M1-20060518/java/sampleapps/pom.xml | 93 +++++ .../java-M1-20060518/java/sampleapps/readme.htm | 20 + 64 files changed, 5948 insertions(+) create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/LICENSE.txt create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/README.txt create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/build.xml create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/pom.xml create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/readme.htm create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuote.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteService.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/DasAccountConfiguration.xml create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/WebservicexService_stockquote.fragment create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/mock_stockquote.fragment create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/sca.fragment create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/sca.module create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/sca.subsystem create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/wsdl/AccountService.wsdl create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/wsdl/stockquotes.webservicex.wsdl create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/test/java/bigbank/account/client/AccountClient.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/build.xml create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/Show.Image.html create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/accountfiles.png create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/modualoverview.png create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/webclientfiles.png create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/pom.xml create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/readme.htm create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/LICENSE.txt create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/README.txt create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/build.xml create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/pom.xml create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/readme.htm create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileService.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/SimpleLoginServiceImpl.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/resources/sca.module create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/resources/sca.subsystem create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/resources/wsdl/AccountService.wsdl create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/CustomerProfile.jsp create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/WEB-INF/bigbank-tags.tld create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/accountTransaction.jsp create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/login.html create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/purchaseStock.jsp create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/stockSale.jsp create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/summary.jsp create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/test/java/bigbank/webclient/client/TestAccountService.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/test/java/bigbank/webclient/client/TestLoginService.java create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/build.xml create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/pom.xml create mode 100644 sca-java-1.x/tags/java-M1-20060518/java/sampleapps/readme.htm (limited to 'sca-java-1.x/tags/java-M1-20060518/java/sampleapps') diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/LICENSE.txt b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/LICENSE.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/README.txt b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/README.txt new file mode 100644 index 0000000000..9b26d1690a --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/README.txt @@ -0,0 +1,35 @@ +Apache Tuscany M1 build (May, 2006) +=================================== + +http://incubator.apache.org/tuscany/ + +Tuscany is an effort undergoing incubation at the Apache Software Foundation +(ASF), sponsored by the Web Services PMC. + +Incubation is required of all newly accepted projects until a further review +indicates that the infrastructure, communications, and decision making process +have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness or +stability of the code, it does indicate that the project has yet to be fully +endorsed by the ASF. + + +Support +------- + +Any problem with this release can be reported to the Tuscany mailing list +or in the JIRA issue tracker. + +Mailing list subscription: + tuscany-dev-subscribe@ws.apache.org + +Jira: + http://issues.apache.org/jira/browse/Tuscany + + +Thank you for using Tuscany! + + +The Tuscany Team. + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/build.xml b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/build.xml new file mode 100644 index 0000000000..5d53fde251 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/build.xml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/pom.xml b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/pom.xml new file mode 100644 index 0000000000..4a7bc56abf --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/pom.xml @@ -0,0 +1,125 @@ + + + + + org.apache.tuscany.samples.bigbank + bigbank-scenario + incubating-M1 + + 4.0.0 + sample-bigbank-account + war + Tuscany BigBank Account Module + BigBank Scenario - Account Management Module + incubating-M1 + + + + org.apache.tuscany + tuscany-core + ${pom.version} + provided + + + org.apache.tuscany.sca.containers + tuscany-container-java + ${pom.version} + provided + + + org.apache.tuscany.sca.bindings + tuscany-binding-axis2 + ${pom.version} + provided + + + org.apache.tuscany.das + tuscany-das-rdb + ${pom.version} + provided + + + javax.servlet + servlet-api + 2.4 + provided + + + org.apache.derby + derby + 10.1.2.1 + provided + + + + junit + junit + 3.8.1 + test + + + + + + + org.apache.tuscany + tuscany-sdo-plugin + + + + + ${basedir}/src/main/resources/wsdl + true + true + true + + + generate + + + + + + org.apache.tuscany.sca.plugins + tuscany-plugin-wsdl2java + + + + + + ${basedir}/src/main/resources/wsdl/stockquotes.webservicex.wsdl + + + StockQuoteSoap + + + + + ${basedir}/src/main/resources/wsdl/AccountService.wsdl + + + + + generate + + + + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/readme.htm b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/readme.htm new file mode 100644 index 0000000000..d7e35ae92b --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/readme.htm @@ -0,0 +1,20 @@ + + + + + + + + + Tuscany Hello World Web Sample + + + + + + +Please see +../readme.htm + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java new file mode 100644 index 0000000000..304244b7db --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java @@ -0,0 +1,260 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.account.services.account; + +import java.rmi.RemoteException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.TimeZone; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import bigbank.account.services.accountdata.AccountDataService; +import bigbank.account.services.stockquote.StockQuote; +import bigbank.account.services.stockquote.StockQuoteService; + +import com.bigbank.account.AccountReport; +import com.bigbank.account.AccountService; +import com.bigbank.account.AccountSummary; +import com.bigbank.account.CustomerProfileData; +import com.bigbank.account.StockSummary; + +@Service(interfaces = AccountService.class) +public class AccountServiceImpl implements AccountService { + + public static final String CHECKING_ACCOUNT_PREFIX = "134-43-394"; + + public static final String SAVINGS_ACCOUNT_PREFIX = "134-42-623"; + + public static final String ACCOUNT_TYPE_SAVINGS = "savings"; + + public static final String ACCOUNT_TYPE_CHECKINGS = "checkings"; + + public static final DateFormat tsformatXSDDateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz"); + static { + AccountServiceImpl.tsformatXSDDateTime.setTimeZone(TimeZone.getTimeZone("UTC")); + } + + private float currencyConversion = 1.0f; + private String currency= "USD"; + + @Property + public void setCurrency(final String currency) { + this.currency= currency == null ? this.currency: currency.trim(); + + if ("USD".equals(this.currency)) + currencyConversion= 1.0f; + else if ("EURO".equals(this.currency)) + currencyConversion= 0.8f; + else{ + try { + currencyConversion = Float.parseFloat(this.currency); + } catch (Exception e) { + currencyConversion= 1.0f; + } + + } + + } + + private AccountDataService accountDataService; + + @Reference + public void setAccountDataService(AccountDataService accountDataService) { + this.accountDataService = accountDataService; + } + + private StockQuoteService stockQuoteService; + + @Reference + public void setStockQuoteService(StockQuoteService stockQuoteService) { + this.stockQuoteService = stockQuoteService; + } + + public AccountServiceImpl() { + } + + @SuppressWarnings("unchecked") + public AccountReport getAccountReport(int customerID) throws RemoteException { + + try { + AccountReport accountReport = accountDataService.getAccountReport(customerID); + //convert to local currency. + List accounts = accountReport.getAccountSummaries(); + for(AccountSummary accountSummary : accounts){ + accountSummary.setBalance(fromUSDollarToCurrency(accountSummary.getBalance())); + + } + return updateStockInformation(accountReport); + } catch (Exception e) { + e.printStackTrace(); + if (e instanceof RemoteException) + throw (RemoteException) e; + else + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + } + + private AccountReport updateStockInformation(AccountReport accountReport) throws RemoteException { + List stocks = accountReport.getStockSummaries(); + if (stocks.size() < 1) + return accountReport; // nothing todo + HashSet owned = new HashSet(stocks.size()); + for (StockSummary stock : stocks) { + owned.add(stock.getSymbol()); + } + ArrayList ownedStr = new ArrayList(owned.size() * 5); + for (String s : owned) { + + ownedStr.add(s); + } + + Map stockInfo = stockQuoteService.getQuotes((String[]) ownedStr.toArray(new String[owned.size()])); + + for (StockSummary stock : stocks) { + String symbol = stock.getSymbol(); + StockQuote stockquote = stockInfo.get(symbol); + if (stockquote == null) { + stock.setCurrentPrice(Float.NaN); + stock.setCompany("*not found*"); + stock.setHighPrice(Float.NaN); + stock.setLowPrice(Float.NaN); + + } else { + stock.setCurrentPrice(fromUSDollarToCurrency(convertToFloat(stockquote.getStockQuote()))); + stock.setCompany(stockquote.getCompanyName()); + stock.setHighPrice(fromUSDollarToCurrency(convertToFloat(stockquote.getDayHighPrice()))); + stock.setLowPrice(fromUSDollarToCurrency(convertToFloat(stockquote.getDayLowPrice()))); + } + } + + return accountReport; + } + + float convertToFloat(final String s) { + + try { + return Float.parseFloat(s); + } catch (Exception e) { + return Float.NaN; + } + + } + + private float fromUSDollarToCurrency(float value) { + return value * currencyConversion ; + + + } + private float toUSDollarfromCurrency(float value) { + + return value /currencyConversion ; + } + + + public CustomerProfileData getCustomerProfile(String logonID) throws RemoteException { + + try { + return accountDataService.getCustomerProfile(logonID); + } catch (Exception e) { + e.printStackTrace(); + if (e instanceof RemoteException) + throw (RemoteException) e; + else + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + + } + + public float deposit(String account, float ammount) throws RemoteException { + try { + return accountDataService.deposit(account, toUSDollarfromCurrency(ammount)); + } catch (RemoteException e) { + e.printStackTrace(); + throw e; + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + } + + public StockSummary purchaseStock(int id, StockSummary stock) throws RemoteException { + try { + String symbol = stock.getSymbol(); + Map stockInfo = stockQuoteService.getQuotes(new String[] { symbol }); + + StockQuote stockQuote = stockInfo.get(symbol); + stock.setPurchasePrice(Float.parseFloat(stockQuote.getStockQuote())); + String purchaseDate = tsformatXSDDateTime.format(new Date()); + if (purchaseDate.endsWith("UTC")) + purchaseDate = purchaseDate.substring(0, purchaseDate.length() - 3) + "Z"; + stock.setPurchaseDate(purchaseDate); + + return accountDataService.purchaseStock(id, stock); + } catch (RemoteException e) { + e.printStackTrace(); + throw e; + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + } + + public StockSummary sellStock(int purchaseLotNumber, int quantity) throws RemoteException { + try { + return accountDataService.sellStock(purchaseLotNumber, quantity); + } catch (RemoteException e) { + e.printStackTrace(); + throw e; + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + } + + public float withdraw(String account, float ammount) throws RemoteException { + try { + return accountDataService.withdraw(account, toUSDollarfromCurrency(ammount)); + } catch (RemoteException e) { + e.printStackTrace(); + throw e; + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + } + + public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings) + throws RemoteException { + try { + return accountDataService.createAccount(customerProfile, createSavings, createCheckings); + } catch (RemoteException e) { + e.printStackTrace(); + throw e; + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + } +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java new file mode 100644 index 0000000000..4c44ca307e --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java @@ -0,0 +1,77 @@ +/** + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.account.services.accountdata; + + +public interface AccountDataService { + + /** + * Auto generated method signatures + * @param param0* @param param1* @param param2 + */ + public com.bigbank.account.StockSummary purchaseStock( + int param0,com.bigbank.account.StockSummary parm1) throws java.rmi.RemoteException; + + + /** + * Auto generated method signatures + * @param param4 + */ + public com.bigbank.account.CustomerProfileData getCustomerProfile( + java.lang.String param4) throws java.rmi.RemoteException; + + + /** + * Auto generated method signatures + * @param param6* @param param7 + */ + public float deposit( + java.lang.String param6,float param7) throws java.rmi.RemoteException; + + + /** + * Auto generated method signatures + * @param param9* @param param10* @param param11 + */ + public com.bigbank.account.CustomerProfileData createAccount( + com.bigbank.account.CustomerProfileData param9,boolean param10,boolean param11) throws java.rmi.RemoteException; + + + /** + * Auto generated method signatures + * @param param13* @param param14 + */ + public com.bigbank.account.StockSummary sellStock( + int param13,int param14) throws java.rmi.RemoteException; + + + /** + * Auto generated method signatures + * @param param16* @param param17 + */ + public float withdraw( + java.lang.String param16,float param17) throws java.rmi.RemoteException; + + + /** + * Auto generated method signatures + * @param param19 + */ + public com.bigbank.account.AccountReport getAccountReport( + int param19) throws java.rmi.RemoteException; + + + } diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java new file mode 100644 index 0000000000..39c319b7a5 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java @@ -0,0 +1,397 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.account.services.accountdata; + +import java.io.InputStream; +import java.rmi.RemoteException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.List; +import java.util.Properties; +import java.util.TimeZone; + +import org.apache.tuscany.das.rdb.ApplyChangesCommand; +import org.apache.tuscany.das.rdb.Command; +import org.apache.tuscany.das.rdb.CommandGroup; +import org.apache.tuscany.das.rdb.Converter; +import org.osoa.sca.annotations.Service; + +import bigbank.account.services.account.AccountServiceImpl; + +import com.bigbank.account.AccountFactory; +import com.bigbank.account.AccountReport; +import com.bigbank.account.AccountSummary; +import com.bigbank.account.CustomerProfileData; +import com.bigbank.account.DataGraphRoot; +import com.bigbank.account.StockSummary; +import commonj.sdo.DataObject; +import commonj.sdo.helper.TypeHelper; + +@Service(AccountDataService.class) +public class AccountDataServiceDASImpl implements AccountDataService { + + static public String dbDirectory = null; + + public static final DateFormat tsformatXSDDateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz"); + + public static final DateFormat sqlformatDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSz"); + + static { + tsformatXSDDateTime.setTimeZone(TimeZone.getTimeZone("UTC")); + + } + + public CustomerProfileData getCustomerProfile(String logonID) throws RemoteException { + + try { + InputStream mapping = createConfigStream(); + Command select = Command.FACTORY.createCommand( + "SELECT firstName, lastName, loginID, password, id FROM customers where loginID = :loginID", mapping); + Connection conn = getConnection(); + select.setConnection(conn); + select.setParameterValue("loginID", logonID); + TypeHelper helper = TypeHelper.INSTANCE; + + select.setDataObjectModel(helper.getType(DataGraphRoot.class)); + + DataGraphRoot root = (DataGraphRoot) select.executeQuery(); + conn.close(); + + Collection customers = root.getCustomerProfileData(); + CustomerProfileData customerProfileData = (CustomerProfileData) customers.iterator().next(); + + + return customerProfileData; + } catch (Exception e) { + + e.printStackTrace(); + RemoteException re = new RemoteException("Failed to get customer profile'" + logonID + "' ", e); + re.printStackTrace(); + throw re; + } + } + + protected static final String driver = "org.apache.derby.jdbc.EmbeddedDriver"; + + protected static final String protocol = "jdbc:derby:"; + + public CustomerProfileData testgetCustomerByLoginIDThroughDASRead(final String logonID) throws Exception { + + InputStream mapping = createConfigStream(); + + Command select = Command.FACTORY.createCommand("SELECT firstName, lastName, loginID, password, id FROM customers where loginID = :loginID", + mapping); + Connection conn = getConnection(); + select.setConnection(conn); + select.setParameterValue("loginID", logonID); + TypeHelper helper = TypeHelper.INSTANCE; + + select.setDataObjectModel(helper.getType(DataGraphRoot.class)); + + DataGraphRoot root = (DataGraphRoot) select.executeQuery(); + conn.close(); + + Collection customers = root.getCustomerProfileData(); + CustomerProfileData customerProfileData = (CustomerProfileData) customers.iterator().next(); + return customerProfileData; + + } + + public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings) + throws RemoteException { + + try { + Command insert = Command.FACTORY.createCommand("insert into customers (firstName,lastName,address,email, loginID, password ) values ('" + + customerProfile.getFirstName() + "', '" + customerProfile.getLastName() + "', '" + customerProfile.getAddress() + "', '" + + customerProfile.getEmail() + "', '" + customerProfile.getLoginID() + "', '" + customerProfile.getPassword() + "')"); + insert.setConnection(getConnection()); + insert.execute(); + CustomerProfileData ret = getCustomerProfile(customerProfile.getLoginID()); + String cid = ret.getId() + ""; + if (createSavings) { + insert = Command.FACTORY.createCommand("insert into accounts (id,accountNumber, accountType, balance ) values (" + cid + ", '" + + AccountServiceImpl.SAVINGS_ACCOUNT_PREFIX + cid + "', '" + AccountServiceImpl.ACCOUNT_TYPE_SAVINGS + "', " + 1.0F + ")"); + insert.setConnection(getConnection()); + insert.execute(); + + } + if (createCheckings) { + insert = Command.FACTORY.createCommand("insert into accounts (id,accountNumber, accountType, balance ) values (" + cid + ", '" + + AccountServiceImpl.CHECKING_ACCOUNT_PREFIX + cid + "', '" + AccountServiceImpl.ACCOUNT_TYPE_CHECKINGS + "', " + 1.0F + ")"); + insert.setConnection(getConnection()); + insert.execute(); + + } + + return ret; + } catch (Exception e) { + if (e instanceof RemoteException) + throw (RemoteException) e; + throw new RemoteException("createAccount " + e.getClass().getName() + "'. " + e.getMessage(), e); + } + } + + public CustomerProfileData createAccountNOTWORKING(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings) + throws RemoteException { + try { + CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(createConfigStream()); + commandGroup.setConnection(getConnection()); + Command read = commandGroup.getCommand("all customers"); + + // select.setDataObjectModel(); + TypeHelper helper = TypeHelper.INSTANCE; + read.setDataObjectModel(helper.getType(DataGraphRoot.class)); + DataObject root = read.executeQuery(); + + // Create a new stockPurchase + DataObject customer = root.createDataObject("customerProfileData"); + + // THIS SEEMS TO BE THE ONLY WAY TO DO THIS .. NO WAY TO JUST ADD AN EXISTING CUSTOMER. + customer.set("firstName", customerProfile.getFirstName()); + customer.set("lastName", customerProfile.getLastName()); + customer.set("address", customerProfile.getAddress()); + customer.set("email", customerProfile.getEmail()); + customer.set("loginID", customerProfile.getLoginID()); + customer.set("password", customerProfile.getPassword()); + + ApplyChangesCommand apply = commandGroup.getApplyChangesCommand(); + apply.execute(root); + return getCustomerProfile(customerProfile.getLoginID()); + + } catch (Exception e) { + if (e instanceof RemoteException) + throw (RemoteException) e; + throw new RemoteException("createAccount " + e.getClass().getName() + "'. " + e.getMessage(), e); + } + + } + + public AccountReport getAccountReport(final int customerID) throws RemoteException { + try { + final AccountFactory accountFactory = AccountFactory.INSTANCE; + final AccountReport accountReport = accountFactory.createAccountReport(); + InputStream mapping = createConfigStream(); + + Command select = Command.FACTORY.createCommand("SELECT accountNumber, accountType, balance FROM accounts where id = :id", mapping); + Connection conn = getConnection(); + select.setConnection(conn); + select.setParameterValue("id", customerID); + TypeHelper helper = TypeHelper.INSTANCE; + select.setDataObjectModel(helper.getType(DataGraphRoot.class)); + DataGraphRoot root = (DataGraphRoot) select.executeQuery(); + accountReport.getAccountSummaries().addAll(root.getAccountSummaries()); + + // Get Stocks + + select = Command.FACTORY.createCommand( + "SELECT Symbol, quantity, purchasePrice, purchaseDate, purchaseLotNumber FROM stocks where id = :id", createConfigStream()); + select.setConnection(conn); + select.setParameterValue("id", customerID); + select.setDataObjectModel(helper.getType(DataGraphRoot.class)); + + // select.addConverter("STOCKS.PURCHASEDATE", DateConverter.class.getName()); + + root = (DataGraphRoot) select.executeQuery(); + accountReport.getStockSummaries().addAll(root.getStockSummaries()); + + conn.close(); + + return accountReport; + } catch (Exception e) { + if (e instanceof RemoteException) + throw (RemoteException) e; + throw new RemoteException("getAccountReport failed. customerID ('" + customerID + "')" + e.getClass().getName() + "'. " + e.getMessage(), + e); + } + } + + public float withdraw(String account, float ammount) throws RemoteException { + + return deposit(account, -ammount); + } + + public float deposit(String account, float ammount) throws RemoteException { + + try { + Command select = Command.FACTORY.createCommand("SELECT accountNumber, balance FROM accounts where accountNumber = :accountNumber", + createConfigStream()); + Connection conn = getConnection(); + select.setConnection(conn); + select.setParameterValue("accountNumber", account); + TypeHelper helper = TypeHelper.INSTANCE; + select.setDataObjectModel(helper.getType(DataGraphRoot.class)); + DataGraphRoot root = (DataGraphRoot) select.executeQuery(); + Collection accounts = root.getAccountSummaries(); + AccountSummary accountData = (AccountSummary) accounts.iterator().next(); + float newbalance = accountData.getBalance() + ammount; + accountData.setBalance(newbalance); + // update department set companyid = ? where department.name = ? + CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(createConfigStream()); + commandGroup.setConnection(conn); + Command update = commandGroup.getCommand("update balance"); + update.setParameterValue("BALANCE", new Float(newbalance)); + update.setParameterValue("ACCOUNTNUMBER", account); + update.execute(); + conn.close(); + return newbalance; + } catch (Exception e) { + throw new RemoteException(e.getClass().getName(), e); + } + + } + + public StockSummary sellStock(int purchaseLotNumber, int quantity) throws RemoteException { + try { + CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(createConfigStream()); + commandGroup.setConnection(getConnection()); + + Command read = commandGroup.getCommand("stockbylotSelect"); + TypeHelper helper = TypeHelper.INSTANCE; + read.setDataObjectModel(helper.getType(DataGraphRoot.class)); + read.setParameterValue("PURCHASELOTNUMBER", purchaseLotNumber);// autoboxing :-) + DataGraphRoot root = (DataGraphRoot) read.executeQuery(); + List stocks = root.getStockSummaries(); + if (null != stocks && !stocks.isEmpty()) { + StockSummary stock = (StockSummary) stocks.get(0); + int newQuatity = Math.max(stock.getQuantity() - quantity, 0); + if (newQuatity < 1) { + + Command delete = Command.FACTORY.createCommand("DELETE FROM STOCKS WHERE PURCHASELOTNUMBER = ?"); + delete.setParameterValue(1, purchaseLotNumber); + delete.setConnection(getConnection()); + delete.execute(); + + } else { + + Command update = commandGroup.getCommand("stockbylot"); + + update.setParameterValue("QUANTITY", newQuatity); + update.setParameterValue("PURCHASELOTNUMBER", purchaseLotNumber); + update.execute(); + + stock.setQuantity(newQuatity); + } + + } + + return null; + } catch (Exception e) { + throw new RemoteException("sellStock", e); + } + } + + public StockSummary purchaseStock(int id, StockSummary stock) throws RemoteException { + + try { + + Command insert = Command.FACTORY + .createCommand("insert into stocks (id, symbol, quantity, purchasePrice, purchaseDate) values (?,?,?,?,?)"); + insert.setParameterValue(1, new Integer(id)); + insert.setParameterValue(2, stock.getSymbol()); + insert.setParameterValue(3, stock.getQuantity()); + insert.setParameterValue(4, stock.getPurchasePrice()); + insert.setParameterValue(5, DateConverter.INSTANCE.getColumnValue(stock.getPurchaseDate())); + + insert.setConnection(getConnection()); + insert.execute(); + + return stock; + } catch (Exception e) { + if (e instanceof RemoteException) + throw (RemoteException) e; + throw new RemoteException("purchaseStock " + e.getClass().getName() + "'. " + e.getMessage(), e); + } + } + + protected Connection getConnection() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException { + Connection conn; + Class.forName(driver).newInstance(); + Properties props = new Properties(); + // props.put("user", "tuscany"); + // props.put("password", "tuscany"); + conn = DriverManager.getConnection(protocol + dbDirectory + ";create=true", props); + + conn.setAutoCommit(false); + return conn; + } + + protected InputStream createConfigStream() { + InputStream mapping = getClass().getClassLoader().getResourceAsStream("DasAccountConfiguration.xml"); + return mapping; + } + + public static class DateConverter implements Converter { + public final static DateConverter INSTANCE = new DateConverter(); + + public DateConverter() { + } + + public Object getPropertyValue(Object columnData) { + + try { + + String ret = tsformatXSDDateTime.format(columnData); + if (ret.endsWith("UTC")) + ret = ret.substring(0, ret.length() - 3) + "Z"; + return ret; + + } catch (Exception e) { + + e.printStackTrace(); + throw new IllegalArgumentException(e); + } + + } + + public Object getColumnValue(Object propertyData) { + + if (propertyData instanceof java.util.Date) { + // Need to convert back to local time for DB and remove timezone notation at the end.. + String ret = sqlformatDateTime.format(propertyData); + char lc = ret.charAt(ret.length() - 1); + while (!Character.isDigit(lc)) { + ret = ret.substring(0, ret.length() - 1); + lc = ret.charAt(ret.length() - 1); + } + return ret; + } else if (propertyData instanceof String) { + + try { + String time = (String) propertyData; + char last = time.charAt(time.length() - 1); + if (last == 'z' || last == 'Z') { + time = time.substring(0, time.length() - 1); + } + if (!time.endsWith("UTC")) { + time = time + "UTC"; + } + return getColumnValue(tsformatXSDDateTime.parse(time)); + } catch (ParseException e) { + throw new IllegalArgumentException("'" + propertyData + "' does not parse to date."); + } + } else + throw new IllegalArgumentException(); + + } + + } +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java new file mode 100644 index 0000000000..3b9a64dda5 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java @@ -0,0 +1,99 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.account.services.accountdata; + +import java.rmi.RemoteException; +import java.util.List; + +import org.osoa.sca.annotations.Service; + +import com.bigbank.account.AccountFactory; +import com.bigbank.account.AccountReport; +import com.bigbank.account.AccountSummary; +import com.bigbank.account.CustomerProfileData; +import com.bigbank.account.StockSummary; + +@Service(AccountDataService.class) +public class AccountDataServiceImpl implements AccountDataService { + + public CustomerProfileData getCustomerProfile(String logonID) throws RemoteException { + // TODO Auto-generated method stub + return null; + } + + public AccountReport getAccountReport(int customerID) { + final AccountFactory accountFactory = AccountFactory.INSTANCE; + AccountReport accountReport = accountFactory.createAccountReport(); + List accounts = accountReport.getAccountSummaries(); + + AccountSummary account = accountFactory.createAccountSummary(); + account.setAccountType("1111"); + account.setAccountNumber("22-22-22"); + account.setBalance(123.45F); + accounts.add(account); + + account = accountFactory.createAccountSummary(); + account.setAccountType("04-11-19"); + account.setAccountNumber("11-23"); + account.setBalance(543.21F); + accounts.add(account); + + List stocks = accountReport.getStockSummaries(); + StockSummary stock = accountFactory.createStockSummary(); + stock.setSymbol("IBM"); + stock.setPurchaseDate("1999-11-23"); + stock.setPurchaseLotNumber(101); + stock.setPurchasePrice(33.33F); + stock.setQuantity(10); + stocks.add(stock); + + stock = accountFactory.createStockSummary(); + stock.setSymbol("TUSK"); + stock.setPurchaseDate("2005-01-05"); + stock.setPurchaseLotNumber(102); + stock.setPurchasePrice(11.11F); + stock.setQuantity(4); + stocks.add(stock); + return accountReport; + } + + public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings) + throws RemoteException { + // TODO Auto-generated method stub + return null; + } + + public float deposit(String param6, float param7) throws RemoteException { + // TODO Auto-generated method stub + return 0; + } + + public StockSummary purchaseStock(int param0, StockSummary stock) throws RemoteException { + // TODO Auto-generated method stub + return null; + } + + public StockSummary sellStock(int param13, int param14) throws RemoteException { + // TODO Auto-generated method stub + return null; + } + + public float withdraw(String param16, float param17) throws RemoteException { + // TODO Auto-generated method stub + return 0; + } +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java new file mode 100644 index 0000000000..42cf6dde2a --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java @@ -0,0 +1,452 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.account.services.accountdb; + +import java.io.InputStream; +import java.io.PrintStream; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.Date; +import java.util.Properties; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; + +import org.apache.tuscany.das.rdb.ApplyChangesCommand; +import org.apache.tuscany.das.rdb.Command; +import org.apache.tuscany.das.rdb.CommandGroup; +import org.apache.tuscany.das.rdb.Converter; +import org.apache.tuscany.das.rdb.config.ConfigFactory; +import org.apache.tuscany.sdo.util.SDOUtil; + +import bigbank.account.services.account.AccountServiceImpl; +import bigbank.account.services.accountdata.AccountDataServiceDASImpl; + +import com.bigbank.account.AccountFactory; +import com.bigbank.account.AccountSummary; +import com.bigbank.account.CustomerProfileData; +import com.bigbank.account.DataGraphRoot; +import com.bigbank.account.StockSummary; +import com.bigbank.account.purchaseStock; +import com.bigbank.account.withdraw; +import commonj.sdo.DataObject; +import commonj.sdo.helper.TypeHelper; + +public class AccountDBInit extends HttpServlet { + + /** + * + */ + private static final long serialVersionUID = -4795999792460944805L; + + protected static final String driver = "org.apache.derby.jdbc.EmbeddedDriver"; + + protected static final String protocol = "jdbc:derby:"; + + boolean deleteExisting = false; + + protected String dbDirectory = null; + + + @Override + public void init() throws ServletException { + try { + + registerTypes(); + ServletConfig servletConfig = getServletConfig(); + ServletContext servletContext = servletConfig.getServletContext(); + this.dbDirectory = servletContext.getRealPath("WEB-INF/bigbankdb/accounts"); + this.deleteExisting = false; + + createDB(dbDirectory); + + + } catch (Exception e) { + + e.printStackTrace(); + log(e.toString(), e); + throw new ServletException(e); + } + } + + public AccountDBInit() { + } + + public AccountDBInit(String dbDirectory, Boolean deleteExisting) { + this.dbDirectory = dbDirectory; + this.deleteExisting = deleteExisting; + } + + public static void createDB(final String location) throws Exception { + Connection conn = null; + AccountDataServiceDASImpl.dbDirectory = location; + Exception processessingException = null; + try { + conn = createConnection(location); + + creatTables(conn); + + int id = createCustomer(conn, "Test", "User", "304 Fox Trot ln, Apex, NC", "test@das.org", "test", "password"); + createAccount(conn, id, AccountServiceImpl.SAVINGS_ACCOUNT_PREFIX + id, AccountServiceImpl.ACCOUNT_TYPE_SAVINGS, 123.43F); + createAccount(conn, id, AccountServiceImpl.CHECKING_ACCOUNT_PREFIX+id, AccountServiceImpl.ACCOUNT_TYPE_CHECKINGS, 23.12F); + createStockPurchase(conn, id, "IBM", 33, 66.20F, "2005-11-23 13:22:02"); + createStockPurchase(conn, id, "DELL", 13, 12.74F, "2003-01-03 11:04:03"); + createStockPurchase(conn, id, "LU", 7, 2.74F, "2003-01-04 16:04:03"); + createStockPurchase(conn, id, "IBM", 22, 81.43F, "2004-02-03 13:04:33"); + + id = createCustomer(conn, "test2", "demo2", "Pleasant Plains Rd, ViewMount, CO","test2@das.org", "test2", "password"); + createAccount(conn, id, AccountServiceImpl.SAVINGS_ACCOUNT_PREFIX + id, AccountServiceImpl.ACCOUNT_TYPE_SAVINGS, 924.40F); + createAccount(conn, id, AccountServiceImpl.CHECKING_ACCOUNT_PREFIX+id, AccountServiceImpl.ACCOUNT_TYPE_CHECKINGS, 33.26F); + createStockPurchase(conn, id, "FOO", 3, 6.20F, "2000-09-11 09:11:01"); + + + + conn.commit(); + + + + } catch (org.apache.derby.impl.jdbc.EmbedSQLException e) { + if (conn != null && !conn.isClosed()) + conn.rollback(); + if (e.getErrorCode() == 20000 && "X0Y32".equalsIgnoreCase(e.getSQLState()) && -1 != e.getMessage().indexOf("already exists")) { + // this is ok the database is there. + + } else { + + e.printStackTrace(); + processessingException = e; + throw e; + } + } finally { + try { + if (null != conn && !conn.isClosed()) { + + conn.close(); + } + conn = null; + } catch (Exception e) { + e.printStackTrace(); + if (null != processessingException) { + throw e; + } + } + } + + } + + private Connection createConnection() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException { + return createConnection(dbDirectory); + } + + private static Connection createConnection(final String location) throws InstantiationException, IllegalAccessException, ClassNotFoundException, + SQLException { + Connection conn; + Class.forName(driver).newInstance(); + Properties props = new Properties(); + conn = DriverManager.getConnection(protocol + location + ";create=true", props); + + conn.setAutoCommit(false); + return conn; + } + + protected static void creatTables(Connection conn) throws Exception { + + + + Statement s = conn.createStatement(); + s + .execute("create table customers(firstName varchar(80) NOT NULL, lastName varchar(80), address varchar(180),email varchar(40),loginID varchar(80) NOT NULL UNIQUE, password varchar(80), id int NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY)"); + + s.execute("create table accounts(id int NOT NULL, accountNumber varchar(80) NOT NULL UNIQUE, accountType varchar(80), balance real )"); + + s + .execute("create table stocks(id int NOT NULL, Symbol varchar(8) NOT NULL, quantity int NOT NULL, purchasePrice real NOT NULL, purchaseDate TIMESTAMP, purchaseLotNumber int NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY )"); + + s.close(); + } + + protected static int createCustomer(Connection conn, final String firstName, final String lastName, final String address, final String email, final String logonID, final String password) + throws SQLException, Exception { + Statement s = conn.createStatement(); + + s.execute("insert into customers (firstName,lastName,address,email, loginID, password ) values ('" + firstName + "', '" + lastName + "', '"+ address + "', '" + email + "', '" + logonID + + "', '" + password + "')"); + + ResultSet rs = s.executeQuery("SELECT loginID, id FROM customers where loginID='" + logonID + "'"); + if (!rs.next()) { + throw new Exception("Wrong number of rows"); + } + int id = rs.getInt(2); + s.close(); + + return id; + } + + protected static void createAccount(Connection conn, int customerID, final String accountNumber, final String accountType, final float balance) + throws SQLException, Exception { + Statement s = conn.createStatement(); + + s.execute("insert into accounts (id,accountNumber, accountType, balance ) values (" + customerID + ", '" + accountNumber + "', '" + + accountType + "', " + balance + ")"); + + s.close(); + + + } + + protected InputStream createConfigStream() { + InputStream mapping = getClass().getClassLoader().getResourceAsStream("basicStaticCustomer.xml"); + return mapping; + } + + protected static void createStockPurchase(Connection conn, int customerID, final String stockSymbol, final int quantity, final float purchasePrice, + String purchaseDate) throws SQLException, Exception { + Statement s = conn.createStatement(); + + s.execute("insert into stocks (id, symbol, quantity, purchasePrice, purchaseDate ) values (" + customerID + ", '" + stockSymbol + "', " + + quantity + ", " + purchasePrice + ", '" + purchaseDate + "')"); + + s.close(); + + } + + protected static void registerTypes() { + SDOUtil.registerStaticTypes(AccountFactory.class); + // TODO remove + SDOUtil.registerStaticTypes(ConfigFactory.class); + + } + + /** + * @param args + */ + public static void main(String[] args) throws Exception { + registerTypes(); + String dbDirectory = null; // "c:/derbydbtest/foo"; + Boolean deleteExisting = false; + for (String x : args) { + if ("-d".equals(x)) { + deleteExisting = true; + } + if (!x.startsWith("-")) { + dbDirectory = x; + } + + } + AccountDBInit accountDBInit = new AccountDBInit(dbDirectory, deleteExisting); + + createDB(dbDirectory); + accountDBInit.readDBstdout(System.out); + + + // Test withdrawl + withdraw wd = AccountFactory.INSTANCE.createwithdraw(); + wd.setAccountNumber("134-43-39438"); + wd.setAmount(1.00F); + // accountDBInit.testWithdrawThroughDAS(wd); + + // test stock purchase. + + purchaseStock sp = AccountFactory.INSTANCE.createpurchaseStock(); + StockSummary stock= AccountFactory.INSTANCE.createStockSummary(); + sp.setStock(stock); + stock.setSymbol("GOOG"); + sp.setId(1); + stock.setQuantity(10); + accountDBInit.testStrockPurchaseThroughDAS(sp); + + accountDBInit.readDBstdout(System.out); + + System.out.flush(); + } + + protected void testStrockPurchaseThroughDAS(purchaseStock sp) throws InstantiationException, IllegalAccessException, ClassNotFoundException, + SQLException { + + CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(createConfigStream()); + commandGroup.setConnection(createConnection()); + Command read = commandGroup.getCommand("all stocks"); + + DataObject root = read.executeQuery(); + + // Create a new stockPurchase + DataObject stockPurchase = root.createDataObject("STOCKS"); + stockPurchase.set("ID", new Integer(sp.getId())); + stockPurchase.set("SYMBOL", sp.getStock().getSymbol()); + stockPurchase.set("QUANTITY", new Integer(sp.getStock().getQuantity())); + stockPurchase.set("PURCHASEPRICE", new Float(11.00)); + stockPurchase.set("PURCHASEDATE", new Date()); + + ApplyChangesCommand apply = commandGroup.getApplyChangesCommand(); + + apply.execute(root); + + + + } + + public CustomerProfileData testgetCustomerByLoginIDThroughDASRead(final String logonID) throws Exception { + + InputStream mapping = createConfigStream(); + + Command select = Command.FACTORY.createCommand("SELECT firstName, lastName, loginID, password, id FROM customers where loginID = :loginID", + mapping); + Connection conn = createConnection(); + select.setConnection(conn); + select.setParameterValue("loginID", logonID); + TypeHelper helper = TypeHelper.INSTANCE; + + select.setDataObjectModel(helper.getType(DataGraphRoot.class)); + + DataGraphRoot root = (DataGraphRoot) select.executeQuery(); + conn.close(); + + Collection customers = root.getCustomerProfileData(); + CustomerProfileData customerProfileData = (CustomerProfileData) customers.iterator().next(); + System.out.println(customerProfileData); + System.out.flush(); + return customerProfileData; + + } + + protected void readDBstdout(PrintStream stream) throws Exception { + Connection conn = null; + try { + conn = createConnection(dbDirectory); + Statement s = conn.createStatement(); + ResultSet rs = s.executeQuery("SELECT firstName, lastName, loginID, password, id FROM customers ORDER BY lastName"); + while (rs.next()) { + stream.print(rs.getString(1)); + stream.print(" "); + stream.print(rs.getString(2)); + stream.print(" "); + stream.print(rs.getString(3)); + stream.print(" "); + stream.print(rs.getString(4)); + stream.print(" "); + stream.print(rs.getString(5)); + stream.println(); + int id = rs.getInt(5); + Statement s1 = conn.createStatement(); + ResultSet rs1 = s1.executeQuery("SELECT accountNumber, accountType, balance FROM accounts where id=" + id); + while (rs1.next()) { + stream.print("\t"); + stream.print(rs1.getString(1)); + stream.print(" "); + stream.print(rs1.getString(2)); + stream.print(" "); + stream.print(rs1.getString(3)); + stream.println(); + } + rs1.close(); + rs1 = s1.executeQuery("SELECT symbol, quantity, purchasePrice, purchaseDate, purchaseLotNumber FROM stocks where id=" + id); + while (rs1.next()) { + stream.print("\t"); + stream.print(rs1.getString(1)); + stream.print(" "); + stream.print(rs1.getString(2)); + stream.print(" "); + stream.print(rs1.getString(3)); + stream.print(" "); + stream.print(rs1.getString(4)); + stream.print(" "); + stream.print(rs1.getString(5)); + stream.println(); + } + s1.close(); + stream.println(); + + } + s.close(); + conn.commit(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (conn != null) + conn.close(); + conn = null; + } + + } + + public void testWithdrawThroughDAS(withdraw wd) throws Exception { + + Command select = Command.FACTORY.createCommand("SELECT accountNumber, balance FROM accounts where accountNumber = :accountNumber", + createConfigStream()); + Connection conn = createConnection(); + select.setConnection(conn); + select.setParameterValue("accountNumber", wd.getAccountNumber()); + TypeHelper helper = TypeHelper.INSTANCE; + + select.setDataObjectModel(helper.getType(DataGraphRoot.class)); + + DataGraphRoot root = (DataGraphRoot) select.executeQuery(); + + Collection accounts = root.getAccountSummaries(); + AccountSummary account = (AccountSummary) accounts.iterator().next(); + float newbalance = account.getBalance() - wd.getAmount(); + account.setBalance(newbalance); + // update department set companyid = ? where department.name = ? + + CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(createConfigStream()); + commandGroup.setConnection(conn); + Command update = commandGroup.getCommand("update balance"); + update.setParameterValue("BALANCE", new Float(newbalance)); + update.setParameterValue("ACCOUNTNUMBER", wd.getAccountNumber()); + + update.execute(); + conn.close(); + + } + + public static class MyDateConverter implements Converter { + + private static DateFormat tsformat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + + public Object getPropertyValue(Object columnData) { + + try { + return tsformat.parse(columnData.toString()); + } catch (ParseException e) { + + e.printStackTrace(); + throw new IllegalArgumentException(e); + } + + } + + public Object getColumnValue(Object propertyData) { + + if (propertyData instanceof Date) { + return tsformat.format(propertyData); + } else + throw new IllegalArgumentException(); + + } + + } + +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuote.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuote.java new file mode 100644 index 0000000000..627ab7b379 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuote.java @@ -0,0 +1,223 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.account.services.stockquote; + +public class StockQuote { + + private String companyName; + + private String symbol; + + private String stockQuote; + + private String lastUpdated; + + private String change; + + private String openPrice; + + private String dayHighPrice; + + private String dayLowPrice; + + private String volume; + + private String marketCap; + + private String yearRange; + + private String exDividendDate; + + private String dividendYield; + + private String dividendPerShare; + + /** + * + * + * @generated + */ + protected StockQuote() { + super(); + } + + public String getCompanyName() { + return companyName; + } + + public void setCompanyName(String newCompanyName) { + companyName = newCompanyName; + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String newStockTicker) { + symbol = newStockTicker; + } + + public String getStockQuote() { + return stockQuote; + } + + public void setStockQuote(String newStockQuote) { + stockQuote = newStockQuote; + } + + public String getLastUpdated() { + return lastUpdated; + } + + public void setLastUpdated(String newLastUpdated) { + lastUpdated = newLastUpdated; + } + + public String getChange() { + return change; + } + + public void setChange(String newChange) { + change = newChange; + } + + public String getOpenPrice() { + return openPrice; + } + + public void setOpenPrice(String newOpenPrice) { + openPrice = newOpenPrice; + } + + public String getDayHighPrice() { + return dayHighPrice; + } + + public void setDayHighPrice(String newDayHighPrice) { + dayHighPrice = newDayHighPrice; + } + + public String getDayLowPrice() { + return dayLowPrice; + } + + public void setDayLowPrice(String newDayLowPrice) { + dayLowPrice = newDayLowPrice; + } + + public String getVolume() { + return volume; + } + + public void setVolume(String newVolume) { + volume = newVolume; + } + + public String getMarketCap() { + return marketCap; + } + + public void setMarketCap(String newMarketCap) { + marketCap = newMarketCap; + } + + public String getYearRange() { + return yearRange; + } + + public void setYearRange(String newYearRange) { + yearRange = newYearRange; + } + + public String getExDividendDate() { + return exDividendDate; + } + + public void setExDividendDate(String newExDividendDate) { + exDividendDate = newExDividendDate; + } + + public String getDividendYield() { + return dividendYield; + } + + public void setDividendYield(String newDividendYield) { + dividendYield = newDividendYield; + } + + public String getDividendPerShare() { + return dividendPerShare; + } + + public void setDividendPerShare(String newDividendPerShare) { + dividendPerShare = newDividendPerShare; + } + + public String toString() { + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (companyName: "); + result.append(companyName); + result.append(", symbol: "); + result.append(symbol); + result.append(", stockQuote: "); + result.append(stockQuote); + result.append(", lastUpdated: "); + result.append(lastUpdated); + result.append(", change: "); + result.append(change); + result.append(", openPrice: "); + result.append(openPrice); + result.append(", dayHighPrice: "); + result.append(dayHighPrice); + result.append(", dayLowPrice: "); + result.append(dayLowPrice); + result.append(", volume: "); + result.append(volume); + result.append(", marketCap: "); + result.append(marketCap); + result.append(", yearRange: "); + result.append(yearRange); + result.append(", exDividendDate: "); + result.append(exDividendDate); + result.append(", dividendYield: "); + result.append(dividendYield); + result.append(", dividendPerShare: "); + result.append(dividendPerShare); + result.append(')'); + return result.toString(); + } + public StockQuote clone(){ + StockQuote ret = new StockQuote(); + ret.companyName= companyName; + ret.symbol= symbol; + ret.stockQuote= stockQuote; + ret.lastUpdated= lastUpdated; + ret.change= change; + ret.openPrice= openPrice; + ret.dayHighPrice= dayHighPrice; + ret.dayLowPrice= dayLowPrice; + ret.volume= volume; + ret.marketCap= marketCap; + ret.yearRange= yearRange; + ret.exDividendDate= exDividendDate; + ret.dividendYield= dividendYield; + ret.dividendPerShare= dividendPerShare; + return ret; + } + +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteService.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteService.java new file mode 100644 index 0000000000..b899d7cbd0 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteService.java @@ -0,0 +1,29 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.account.services.stockquote; + +import java.rmi.RemoteException; +import java.util.Map; + +/** + * This is the business interface of the HelloWorld service component. + */ +public interface StockQuoteService { + + public Map getQuotes(String[] symbols) throws RemoteException; + +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java new file mode 100644 index 0000000000..039abde4bc --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java @@ -0,0 +1,66 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.account.services.stockquote; + +import java.rmi.RemoteException; +import java.util.Hashtable; +import java.util.Map; +import java.util.Random; + +/* Mock StockQuoteService */ + +public class StockQuoteServiceImpl implements StockQuoteService { + + static Random rn = new Random(); + + static Hashtable stocks = new Hashtable(); + + public synchronized Map getQuotes(String[] symbols) throws RemoteException { + Map ret = new Hashtable(); + for (String sym : symbols) { + sym = sym.toUpperCase(); + if (!ret.containsKey(sym)) { + StockQuote sq = stocks.get(sym); + if (sq == null) { + sq = new StockQuote(); + stocks.put(sym, sq); + sq.setSymbol(sym); + sq.setCompanyName(sym + " INC"); + float val = rn.nextFloat() * 97.0F + 3.0F; + sq.setStockQuote(val + ""); + sq.setDayHighPrice(val + ""); + sq.setDayLowPrice(val + ""); + sq.setOpenPrice(val + ""); + } else { + float diff = (rn.nextFloat() * 2.0F) - 1; + float newval = new Float(sq.getStockQuote()) + diff; // auto boxing cool. + sq.setStockQuote(newval + ""); + float dh = Math.max(newval, new Float(sq.getDayHighPrice())); + sq.setDayHighPrice(dh + ""); + float dl = Math.min(newval, new Float(sq.getDayLowPrice())); + sq.setDayLowPrice(dl + ""); + + } + ret.put(sym, (StockQuote) sq.clone()); + } + + } + + return ret; + } + +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java new file mode 100644 index 0000000000..f5f481ca1b --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java @@ -0,0 +1,150 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.account.services.stockquote; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.lang.reflect.Method; +import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Map; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; + +import net.x.webservice.StockQuoteSoap; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * This class implements the Stock quote service component. + */ +@Service(StockQuoteService.class) +@Scope("MODULE") +public class StockQuoteWebservicexServiceImpl implements StockQuoteService { + + @Reference + public StockQuoteSoap stockQuoteService = null; // Injected by the SCA container. + + /** + * @throws RemoteException + * @see bigbank.account.services.stockquote.StockQuoteService#getQuotes(String[]) + */ + public Map getQuotes(final String[] symbols) throws RemoteException { + try { + assert null != stockQuoteService : "stockQuoteService was not set by the SCA runtime!"; + StringBuilder sb = new StringBuilder(5 * symbols.length); + for (String sym : symbols) { + if (sb.length() != 0) + sb.append(' '); + sb.append(sym); + } + String stockdata = stockQuoteService.GetQuote(sb.toString()); + + InputStream in = new ByteArrayInputStream(stockdata.getBytes()); + XMLInputFactory factory = XMLInputFactory.newInstance(); + XMLStreamReader parser = factory.createXMLStreamReader(in); + ArrayList listQuotes = new ArrayList(); + Hashtable listQuoteHT = new Hashtable(); + MapStock currentStock = null; + StringBuilder currentText = new StringBuilder(100); + for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) { + String lname; + switch (event) { + case XMLStreamConstants.START_ELEMENT: + if (parser.getLocalName() == "Stock") { + + currentStock = new MapStock(); + listQuotes.add(currentStock); + } + break; + case XMLStreamConstants.END_ELEMENT: + lname = parser.getLocalName(); + String mname = "set" + lname; + try { + Method setter = MapStock.class.getMethod(mname, new Class[] { String.class }); + if (setter != null) { + setter.invoke(currentStock, currentText.toString()); + if (lname.equals("Symbol")) { + listQuoteHT.put(currentText.toString(), currentStock); + + } + } + } catch (NoSuchMethodException e) { + + } + // System.err.println(parser.getLocalName() + ":" + currentText.toString()); + currentText.setLength(0); + break; + case XMLStreamConstants.CHARACTERS: + // System.out.print(parser.getText()); + currentText.append(parser.getText()); + break; + case XMLStreamConstants.CDATA: + // System.out.print(parser.getText()); + currentText.append(parser.getText()); + break; + } // end switch + } // end while + parser.close(); + + return listQuoteHT; + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass().getName() + e.getMessage(), e); + } + } + + public static class MapStock extends StockQuote { + + public void setLast(String val) { + super.setStockQuote(val); + } + + public void setDate(String val) { + }; + + public void setTime(String val) { + }; + + public void setHigh(String val) { + super.setDayHighPrice(val); + } + + public void setLow(String val) { + super.setDayLowPrice(val); + } + + public void setOpen(String val) { + super.setOpenPrice(val); + } + + public void setMktCap(String val) { + super.setMarketCap(val); + } + + public void setName(String val) { + super.setCompanyName(val); + } + + } + +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/DasAccountConfiguration.xml b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/DasAccountConfiguration.xml new file mode 100644 index 0000000000..e558e959fa --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/DasAccountConfiguration.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/WebservicexService_stockquote.fragment b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/WebservicexService_stockquote.fragment new file mode 100644 index 0000000000..b52ba7fe06 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/WebservicexService_stockquote.fragment @@ -0,0 +1,32 @@ + + + + + + + + + + StockQuoteWebService + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/mock_stockquote.fragment b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/mock_stockquote.fragment new file mode 100644 index 0000000000..b7c433d6a1 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/mock_stockquote.fragment @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/sca.fragment b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/sca.fragment new file mode 100644 index 0000000000..b7c433d6a1 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/sca.fragment @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/sca.module b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/sca.module new file mode 100644 index 0000000000..b9234573e1 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/sca.module @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + AccountServiceComponent/AccountService + + + + + + USD + + + AccountDataServiceComponent + StockQuoteServiceComponent + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/sca.subsystem b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/sca.subsystem new file mode 100644 index 0000000000..fd6ab20151 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/sca.subsystem @@ -0,0 +1,22 @@ + + + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/wsdl/AccountService.wsdl b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/wsdl/AccountService.wsdl new file mode 100644 index 0000000000..c44b826440 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/wsdl/AccountService.wsdl @@ -0,0 +1,392 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/wsdl/stockquotes.webservicex.wsdl b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/wsdl/stockquotes.webservicex.wsdl new file mode 100644 index 0000000000..e225678888 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/resources/wsdl/stockquotes.webservicex.wsdl @@ -0,0 +1,133 @@ + + + + + + + + + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Get Stock quote for a company Symbol + + + + + + + Get Stock quote for a company Symbol + + + + + + + Get Stock quote for a company Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..af8fae9d35 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,28 @@ + + + + + Tuscany Bigbank Account sample + + + AccountDBInit + bigbank.account.services.accountdb.AccountDBInit + 2 + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/test/java/bigbank/account/client/AccountClient.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/test/java/bigbank/account/client/AccountClient.java new file mode 100644 index 0000000000..32308169ca --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/account/src/test/java/bigbank/account/client/AccountClient.java @@ -0,0 +1,57 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.account.client; + +import java.util.Iterator; + +import org.apache.tuscany.core.client.TuscanyRuntime; +import org.osoa.sca.CurrentModuleContext; +import org.osoa.sca.ModuleContext; +import org.osoa.sca.SCA; + +import com.bigbank.account.AccountReport; +import com.bigbank.account.AccountService; +import com.bigbank.account.AccountSummary; + +public class AccountClient extends SCA { + + public void start() { + } + + public void stop() { + } + + public static void main(String[] args) throws Exception { + TuscanyRuntime tuscany = new TuscanyRuntime("bigbank.account.testclient", null); + tuscany.start(); + ModuleContext moduleContext = CurrentModuleContext.getContext(); + + AccountService accountService = (AccountService) moduleContext.locateService("AccountServiceComponent"); + + AccountReport accountReport = accountService.getAccountReport(12345); + + for (Iterator i = accountReport.getAccountSummaries().iterator(); i.hasNext();) { + AccountSummary accountSummary = (AccountSummary) i.next(); + + System.out.println(accountSummary.getAccountNumber()); + System.out.println(accountSummary.getAccountType()); + System.out.println(accountSummary.getBalance()); + } + + } + +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/build.xml b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/build.xml new file mode 100644 index 0000000000..8697bd1561 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/build.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/Show.Image.html b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/Show.Image.html new file mode 100644 index 0000000000..a06154f6dd --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/Show.Image.html @@ -0,0 +1,22 @@ + + + + + +
+ +
+ + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/accountfiles.png b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/accountfiles.png new file mode 100644 index 0000000000..a430b12ca2 Binary files /dev/null and b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/accountfiles.png differ diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/modualoverview.png b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/modualoverview.png new file mode 100644 index 0000000000..7e6d7ba25e Binary files /dev/null and b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/modualoverview.png differ diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/webclientfiles.png b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/webclientfiles.png new file mode 100644 index 0000000000..bed1a1731a Binary files /dev/null and b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/docs/webclientfiles.png differ diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/pom.xml b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/pom.xml new file mode 100644 index 0000000000..72a4c00405 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/pom.xml @@ -0,0 +1,34 @@ + + + + + org.apache.tuscany.sampleapps + tuscany-sampleapps + incubating-M1 + + 4.0.0 + org.apache.tuscany.samples.bigbank + bigbank-scenario + pom + Tuscany BigBank Scenario Sample + incubating-M1 + + + account + webclient + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/readme.htm b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/readme.htm new file mode 100644 index 0000000000..857a94596f --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/readme.htm @@ -0,0 +1,94 @@ + + +Tuscany BigBank Sample Application + +

Tuscany +BigBank Sample Application

+

Overview

+

The Tuscany BigBank sample application  +shows using the Tuscany SCA runtime to build a  financial +application.

Location

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

Setup

This Setup section is not required if you are +working from a binary distribution. Set up your server as described in +the Tomcat +Setup.  If you are building the sample from source you need to deploy the war files produced in sampleapps\bigbank\account\target and sampleapps\bigbank\webclient\target  +your webapp directory.
+

Running

+Once you've started your web server, use your web browser to view the +following URL http://localhost:8080/sample-bigbank-webclient/
You can either use an already supplied account with Login as test and Password as password, or you can  create a new account.
The +demo is first configured to use a local mock stock quote service that +returns random stock data.  If you want to use an actual stock +quote provider follow these steps:
  • Stop your server by issuing in the apache-tomcat-5.5.17\bin directory
  • Issue shutdown command to stop your web application server.
  • Change the directory to apache-tomcat-5.5.17\webapps\sample-bigbank-account-incubating-M1\WEB-INF\classes
  • Copy the file WebservicexService_stockquote.fragment to sca.fragment
  • Change to the directory  apache-tomcat-5.5.17\bin 
  • issue startup  command to start up the server.
The +sample should now be using the real stock quote provider. The +"sca.fragment" file is loaded and added to the sca.module at runtime.

Introduction

This +example illustrates using Tuscany runtime in building +a financial application using SCA programing model. + The following key concepts are covered: +
  •  Component +implementations. that provide web based  +HTML user interface
  • Component +implementations that provide local +services in Java. Local services implement internal +application business logic such as tracking user state and are not +exposed remotely.
  • Component +implementations that have configuration +properties and service references +to other services
  • Components +that use and configure the +properties and references of component +implementations
  • Entry points +to publish remotable services via a Web Service +binding.
  • External +services to consume remotable services via a Web +Service binding
  • Assembling +implementation, components, entry points and external service into modules. +
  • Creating a module and all of its artifacts as part +of a web application to show a +front-end access to SCA services
  • The +use of Data Access services to persist and retrieve Service Data +Objects from Apache Derby.
  • The +use of  existing Web services in SCA.
BigBank +sample provides the following user services: account balance, making deposits and withdrawals  +to purchase and sell stock, and to view current stock value.
The +sample is organized into two SCA modules: webclient and account. The +webclient module functionality is to provide user information and +obtain user input. The account module is is used to retrieve and store +user information, account information, current stock information and +the purchasing and selling of stock. The two modules interact via web +services through SCA exterenalService and entryPoint.

+Overview of modules.

Webclient


+
Webclient files 
click to enlarge
Java source files implementing SCA components and interfaces.
AccountServiceComponentImpl.javaImplements +the account service.
AccountLoginServiceImpl.javaImplements +the Logiin service.
LoginService.javaInterface +for a services provided by a login  service component.
ProfileService.javaInterface +for a service provided by a profile component.
ProfileServiceImpl.javaImplements +the profile component.
SimpleLoginServiceImpl.javaA +simple in memory login service.
Java source files implementing Web HTML interface.
AccountStatusTag.javaImplements +a jsp tag that displays the account information
StockStatusTag.javaImplements +a jsp tag that displays the stock information.
LoginBarrierTag.javaImplements +a jsp tag that ensures the user is logged in.
ServiceTag.javaPlaces +an SCA service in the JSP page context.
FormServlet.javaProcess +user input and uses the AccountService component.
LoginServlet.javaProcesses +logging in and logout.
Files that will be loaded as resources along classpath.
sca.moduleSCA  module. 
sca.subsystemSCA +subsystem.
AccountService.wsdlWSDL +that  defines the account service.
bigbank-tags.tldDefines +the tag libs for the user interface.
+

Account

+
Webclient files 
click to enlarge
Java source files implementing SCA components and interfaces.
AccountServiceImpl.javaImplements +the account service component.
AccountDataService.javaInterface defined for component implementing  an account's data service.
AccountDataServiceDASImpl.javaA Data Access Service (DAS) implementation of of the Account Data Service.
AccountDataServiceImpl.javaA Data Service implementation not using DAS.
AccountDBInit.javaA utility to just create the database and it table and fill in some initial data.
StockQuote.javaA class to hold the StockQuote information.
StockQuoteService.javaInterface defined for a component implementing a stock quote service.
StockQuoteServiceImpl.javaImplements a fake stock quote service.
StockQuoteWebservicexServiceImpl.javaImplements an actual stock quote service.
Files that will be loaded as resources along classpath.
AccountService.wsdlWSDL +that  defines the account service
stockquotes.webservicex.wsdlActual stock quote service.
DasAccountConfiguration.xmlProvides any needed configuration info including datasource properties, table definitions,
sca.moduleSCA module.
sca.fragrmentLoaded and combined with the existing SCA module.
sca.subsystemProcesses +logging in and logout.
+
diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/LICENSE.txt b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/LICENSE.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/README.txt b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/README.txt new file mode 100644 index 0000000000..9b26d1690a --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/README.txt @@ -0,0 +1,35 @@ +Apache Tuscany M1 build (May, 2006) +=================================== + +http://incubator.apache.org/tuscany/ + +Tuscany is an effort undergoing incubation at the Apache Software Foundation +(ASF), sponsored by the Web Services PMC. + +Incubation is required of all newly accepted projects until a further review +indicates that the infrastructure, communications, and decision making process +have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness or +stability of the code, it does indicate that the project has yet to be fully +endorsed by the ASF. + + +Support +------- + +Any problem with this release can be reported to the Tuscany mailing list +or in the JIRA issue tracker. + +Mailing list subscription: + tuscany-dev-subscribe@ws.apache.org + +Jira: + http://issues.apache.org/jira/browse/Tuscany + + +Thank you for using Tuscany! + + +The Tuscany Team. + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/build.xml b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/build.xml new file mode 100644 index 0000000000..6cabfe08f5 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/build.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/pom.xml b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/pom.xml new file mode 100644 index 0000000000..3b51a419fb --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/pom.xml @@ -0,0 +1,95 @@ + + + + + org.apache.tuscany.samples.bigbank + bigbank-scenario + incubating-M1 + + 4.0.0 + sample-bigbank-webclient + war + Tuscany BigBank Web Client Module + BigBank Scenario Sample - Web Front-End Module + incubating-M1 + + + + org.apache.tuscany + tuscany-core + ${pom.version} + provided + + + tomcat + servlet-api + 5.0.18 + provided + + + tomcat + jsp-api + 5.0.18 + provided + + + + junit + junit + 3.8.1 + test + + + + + + + org.apache.tuscany + tuscany-sdo-plugin + + + + ${basedir}/src/main/resources/wsdl/AccountService.wsdl + true + true + true + + + + generate + + + + + + org.apache.tuscany.sca.plugins + tuscany-plugin-wsdl2java + + + + ${basedir}/src/main/resources/wsdl/AccountService.wsdl + + + generate + + + + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/readme.htm b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/readme.htm new file mode 100644 index 0000000000..d7e35ae92b --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/readme.htm @@ -0,0 +1,20 @@ + + + + + + + + + Tuscany Hello World Web Sample + + + + + + +Please see +../readme.htm + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java new file mode 100644 index 0000000000..7de9658d34 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java @@ -0,0 +1,106 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.webclient.services.account; + +import java.rmi.RemoteException; + +import org.osoa.sca.ServiceUnavailableException; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import com.bigbank.account.AccountReport; +import com.bigbank.account.AccountService; +import com.bigbank.account.CustomerProfileData; +import com.bigbank.account.StockSummary; + +/** + */ +@Service(AccountService.class) +public class AccountServiceComponentImpl implements AccountService { + + private AccountService accountService; + + @Reference + public void setAccountService(AccountService accountService) { + this.accountService = accountService; + } + + /** + * + */ + public AccountServiceComponentImpl() { + super(); + } + + /** + * @see bigbank.account.services.account.AccountService#getAccountReport(java.lang.String) + */ + public AccountReport getAccountReport(int customerID) { + try { + return accountService.getAccountReport(customerID); + } catch (Exception e) { + throw new ServiceUnavailableException(e); + } + } + + public StockSummary purchaseStock(int customerID, StockSummary stockSummary) throws RemoteException { + try { + return accountService.purchaseStock(customerID, stockSummary); + } catch (Exception e) { + throw new ServiceUnavailableException(e); + } + } + + public CustomerProfileData getCustomerProfile(String param2) throws RemoteException { + try { + return accountService.getCustomerProfile(param2); + } catch (Exception e) { + throw new ServiceUnavailableException(e); + } + } + + public float deposit(String account, float amount) throws RemoteException { + try { + return accountService.deposit(account, amount); + } catch (Exception e) { + throw new ServiceUnavailableException(e); + } + } + + public StockSummary sellStock(int purchaseLotNumber, int quantity) throws RemoteException { + try { + return accountService.sellStock(purchaseLotNumber, quantity); + } catch (Exception e) { + throw new ServiceUnavailableException(e); + } + } + + public float withdraw(String account, float amount) throws RemoteException { + try { + return accountService.withdraw(account, amount); + } catch (Exception e) { + throw new ServiceUnavailableException(e); + } + } + + public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings) + throws RemoteException { + + return accountService.createAccount(customerProfile, createSavings, createCheckings); + } + +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java new file mode 100644 index 0000000000..0de0ef85c3 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java @@ -0,0 +1,50 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.webclient.services.profile; + +import java.rmi.RemoteException; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import com.bigbank.account.AccountService; +import com.bigbank.account.CustomerProfileData; + +@Service(LoginService.class) +public class AccountLoginServiceImpl implements LoginService { + @Reference + public AccountService accountService; + + @Reference + public ProfileService profileService; + + public int login(String userName, String password) throws RemoteException { + + CustomerProfileData profileData = accountService.getCustomerProfile(userName); + + if (!password.equals(profileData.getPassword())) { + return INVALID_PASSWORD; + } + + profileService.setLoggedIn(true); + profileService.setFirstName(profileData.getFirstName()); + profileService.setLastName(profileData.getLastName()); + profileService.setId(profileData.getId()); + + return SUCCESS; + } +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java new file mode 100644 index 0000000000..465c1b3e7e --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java @@ -0,0 +1,30 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.webclient.services.profile; + +import java.rmi.RemoteException; + +public interface LoginService { + + public static final int SUCCESS = 1; + + public static final int INVALID_LOGIN = -1; + + public static final int INVALID_PASSWORD = -2; + + public int login(String userName, String password) throws RemoteException; +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileService.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileService.java new file mode 100644 index 0000000000..2cbfbf489a --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileService.java @@ -0,0 +1,36 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.webclient.services.profile; + +public interface ProfileService { + + public String getFirstName(); + + public void setFirstName(String pName); + + public String getLastName(); + + public void setLastName(String pName); + + public boolean isLoggedIn(); + + public void setLoggedIn(boolean pStatus); + + public int getId(); + + public void setId(int pId); +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java new file mode 100644 index 0000000000..4ae808f31a --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java @@ -0,0 +1,67 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.webclient.services.profile; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(ProfileService.class) +@Scope("session") +public class ProfileServiceImpl implements ProfileService { + + private String firstName; + + public String getFirstName() { + return firstName; + } + + @Property + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + private String lastName; + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + private boolean loggedIn; + + public boolean isLoggedIn() { + return loggedIn; + } + + public void setLoggedIn(boolean status) { + loggedIn = status; + } + + private int id; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/SimpleLoginServiceImpl.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/SimpleLoginServiceImpl.java new file mode 100644 index 0000000000..a8d57fb506 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/SimpleLoginServiceImpl.java @@ -0,0 +1,49 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.webclient.services.profile; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +@Service(LoginService.class) +public class SimpleLoginServiceImpl implements LoginService { + + public ProfileService profileService; + + @Reference + public void setProfileService(ProfileService profileService) { + this.profileService = profileService; + } + + public int login(String userName, String password) { + + if (!"test".equals(userName)) { + return INVALID_LOGIN; + } + + if (!"password".equals(password)) { + return INVALID_PASSWORD; + } + + profileService.setLoggedIn(true); + profileService.setFirstName("John"); + profileService.setLastName("Doe"); + profileService.setId(12345); + + return SUCCESS; + } +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java new file mode 100644 index 0000000000..c11d3f9e46 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java @@ -0,0 +1,125 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.webclient.tags.account; + +import java.util.Iterator; +import java.util.List; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.TagSupport; + +import org.osoa.sca.CurrentModuleContext; +import org.osoa.sca.ModuleContext; + +import bigbank.webclient.services.profile.ProfileService; + +import com.bigbank.account.AccountReport; +import com.bigbank.account.AccountService; + +/** + * Retrieves and iterates over account summary information for the current profile by accessing the remotable account service component + */ + +public class AccountStatusTag extends TagSupport { + + // ---------------------------------- + // Constructors + // ---------------------------------- + + public AccountStatusTag() { + super(); + } + + // ---------------------------------- + // Methods + // ---------------------------------- + + private String mAccountService; + + public String getAccountService() { + return mAccountService; + } + + public void setAccountService(String pAccountService) { + mAccountService = pAccountService; + } + + private String mProfileService; + + public String getProfileService() { + return mProfileService; + } + + public void setProfileService(String pProfileService) { + mProfileService = pProfileService; + } + + private String mId; + + public String getId() { + return mId; + } + + public void setId(String pId) { + mId = pId; + } + + private Iterator mIterator; + + public int doStartTag() throws JspException { + ModuleContext moduleContext = CurrentModuleContext.getContext(); + ProfileService profile = (ProfileService) moduleContext.locateService(mProfileService); + if (profile == null) { + throw new JspException("Profile [" + mProfileService + "] not found in current module context"); + } + + AccountService service = (AccountService) moduleContext.locateService(mAccountService); + if (service == null) { + throw new JspException("Service [" + mAccountService + "] not found in current module context"); + } + List summaries; + try { + AccountReport accountReport = service.getAccountReport(profile.getId()); + pageContext.setAttribute("StockSummaries", accountReport.getStockSummaries()); + summaries = accountReport.getAccountSummaries(); + } catch (Exception e) { + throw new JspException(e); + } + mIterator = summaries.iterator(); + if (mIterator.hasNext()) { + pageContext.setAttribute(mId, mIterator.next()); + return EVAL_BODY_INCLUDE; + } else { + return SKIP_BODY; + } + } + + public int doAfterBody() { + if (mIterator.hasNext()) { + pageContext.setAttribute(mId, mIterator.next()); + return EVAL_BODY_AGAIN; + } else { + return SKIP_BODY; + } + } + + public void release() { + super.release(); + mId = null; + mIterator = null; + } +} \ No newline at end of file diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java new file mode 100644 index 0000000000..ac0b5f4467 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java @@ -0,0 +1,79 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.webclient.tags.account; + +import java.util.Iterator; +import java.util.List; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.TagSupport; + +/** + * Retrieves and iterates over account summary information for the current profile by accessing the remotable account service component + */ + +public class StockStatusTag extends TagSupport { + + + public StockStatusTag() { + super(); + } + + + private String mId; + + public String getId() { + return mId; + } + + public void setId(String pId) { + mId = pId; + } + + private Iterator mIterator; + + public int doStartTag() throws JspException { + + List summaries = (List) pageContext.getAttribute("StockSummaries"); + if (null == summaries) + return SKIP_BODY; + mIterator = summaries.iterator(); + if (mIterator.hasNext()) { + pageContext.setAttribute(mId, mIterator.next()); + return EVAL_BODY_INCLUDE; + } else { + return SKIP_BODY; + } + } + + public int doAfterBody() { + if (mIterator.hasNext()) { + pageContext.setAttribute(mId, mIterator.next()); + return EVAL_BODY_AGAIN; + } else { + pageContext.setAttribute("StockSummaries", null); + return SKIP_BODY; + } + } + + public void release() { + pageContext.setAttribute("StockSummaries", null); + super.release(); + mId = null; + mIterator = null; + } +} \ No newline at end of file diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java new file mode 100644 index 0000000000..e923596bae --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java @@ -0,0 +1,97 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.webclient.tags.sca; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.TagSupport; + +import org.osoa.sca.CurrentModuleContext; +import org.osoa.sca.ModuleContext; + +import bigbank.webclient.services.profile.ProfileService; + +public class LoginBarrierTag extends TagSupport { + + public LoginBarrierTag() { + super(); + } + + private String mProfile; + + public String getProfile() { + return mProfile; + } + + public void setProfile(String pProfile) { + mProfile = pProfile; + } + + private String mUrl; + + public String getUrl() { + return mUrl; + } + + public void setUrl(String pUrl) { + mUrl = pUrl; + } + + int doPage = EVAL_PAGE; + + + public int doStartTag() throws JspException { + if (mProfile == null || mProfile.length() < 1) { + throw new JspException("Invalid profile location specified"); + } + + ModuleContext moduleContext = CurrentModuleContext.getContext(); + + ProfileService profile = (ProfileService) moduleContext.locateService(mProfile); + + if (profile == null) { + throw new JspException("Profile [" + mProfile + "] not found in current module context"); + } + + if (profile.isLoggedIn()) { + return EVAL_BODY_INCLUDE; + } else { + try { + doPage = SKIP_PAGE; + pageContext.forward(mUrl); + ((HttpServletResponse) (pageContext.getResponse())).sendRedirect("login.html"); + return SKIP_BODY; + } catch (ServletException e) { + throw new JspException("Unable to forward to [" + mUrl + "]"); + } catch (IOException e) { + throw new JspException("Unable to forward to [" + mUrl + "]"); + } + } + } + + public int doEndTag() throws JspException { + return doPage; + } + + public void release() { + super.release(); + } + +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java new file mode 100644 index 0000000000..1fa4252c0c --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java @@ -0,0 +1,98 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.webclient.tags.sca; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.TagSupport; + +import org.osoa.sca.CurrentModuleContext; +import org.osoa.sca.ModuleContext; + +/** + * Places an SCA service in the JSP page context, making it available to other tags corresponding to its id value. + */ + +public class ServiceTag extends TagSupport { + + // ---------------------------------- + // Constructors + // ---------------------------------- + + public ServiceTag() { + super(); + } + + // ---------------------------------- + // Methods + // ---------------------------------- + + private String mName; + + /** + * Returns the name of the SCA service to import into the page context. + */ + public String getName() { + return mName; + } + + /** + * Sets name of the SCA service to import into the page context. + */ + public void setName(String pName) { + mName = pName; + } + + private String mId; + + /** + * Returns the id of the service in the page context + */ + public String getId() { + return mId; + } + + /** + * Sets the id of the service for the page context + */ + + public void setId(String pId) { + mId = pId; + } + + public int doStartTag() throws JspException { + ModuleContext moduleContext = CurrentModuleContext.getContext(); + Object service = moduleContext.locateService(mName); + if (service == null) { + throw new JspException("Service [" + mName + "] not found in current module context"); + } + if (mId == null) { + // if the Id name was not specified, default to the basic name of the + // service + mId = mName; + } + pageContext.setAttribute(mId, service); + return EVAL_BODY_INCLUDE; + } + + public int doEndTag() throws JspException { + return EVAL_PAGE; + } + + public void release() { + super.release(); + } +} \ No newline at end of file diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java new file mode 100644 index 0000000000..bad6d370b0 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java @@ -0,0 +1,156 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.webclient.ui; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.osoa.sca.CurrentModuleContext; +import org.osoa.sca.ModuleContext; + +import bigbank.webclient.services.profile.ProfileService; + +import com.bigbank.account.AccountFactory; +import com.bigbank.account.AccountService; +import com.bigbank.account.CustomerProfileData; +import com.bigbank.account.StockSummary; + +public class FormServlet extends HttpServlet { + + // private ServletContext mContext; + // public void init(ServletConfig pCfg) throws ServletException { + // mContext = pCfg.getServletContext(); + // } + + public void doPost(HttpServletRequest pReq, HttpServletResponse pResp) throws ServletException { + + try { + final String action = pReq.getParameter("action"); + ModuleContext moduleContext = CurrentModuleContext.getContext(); + AccountService accountServices = (AccountService) moduleContext.locateService("AccountServiceComponent"); + if (accountServices == null) { + throw new ServletException("AccountServiceComponent"); + } + ProfileService profileServices = null; + if (!"createAccount".equals(action)) { + profileServices = (ProfileService) moduleContext.locateService("ProfileServiceComponent"); + if (profileServices == null) { + throw new ServletException("ProfileServiceComponent not found."); + } + if (!profileServices.isLoggedIn()) { + throw new ServletException("User id '" + profileServices.getId() + "' not logged on."); + } + } + + if ("createAccount".equals(action)) { + createAccount(pReq, pResp, accountServices); + } else if ("account".equals(action)) { + accountTransaction(pReq, pResp, accountServices); + } else if ("stockPurchase".equals(action)) { + stockPurchase(pReq, pResp, profileServices, accountServices); + } else if ("stockSale".equals(action)) { + stockSale(pReq, pResp, profileServices, accountServices); + } else { + throw new IllegalArgumentException("Unknown action in Form servlet '" + action + "'."); + } + // mContext.getRequestDispatcher("summary.jsp").forward(pReq, pResp); + pResp.sendRedirect("summary.jsp"); + } catch (ServletException e) { + e.printStackTrace(); + throw e; + + } catch (Exception e) { + + throw new ServletException(e); + } + + } + + private void stockSale(HttpServletRequest req, HttpServletResponse resp, ProfileService profileServices, AccountService accountServices) + throws ServletException { + try { + if (!"cancel".equals(req.getParameter("cancel"))) { + + int quantity = Integer.parseInt(req.getParameter("quantity")); + int purchaseLotNumber = Integer.parseInt(req.getParameter("purchaseLotNumber")); + accountServices.sellStock(purchaseLotNumber, quantity); + } + + } catch (Exception e) { + + throw new ServletException("stockSale " + e.getMessage(), e); + } + + } + + private void stockPurchase(HttpServletRequest req, HttpServletResponse resp, ProfileService profileServices, AccountService accountServices) + throws ServletException { + try { + if (!"cancel".equals(req.getParameter("cancel"))) { + + String symbol = req.getParameter("symbol").trim().toUpperCase(); + int quantity = Integer.parseInt(req.getParameter("quantity")); + StockSummary stockSummry = AccountFactory.INSTANCE.createStockSummary(); + stockSummry.setSymbol(symbol); + stockSummry.setQuantity(quantity); + accountServices.purchaseStock(profileServices.getId(), stockSummry); + } + } catch (Exception e) { + throw new ServletException("stockPurchase " + e.getMessage(), e); + } + } + + private void accountTransaction(HttpServletRequest req, HttpServletResponse resp, AccountService accountServices) throws ServletException { + try { + if (!"cancel".equals(req.getParameter("cancel"))) { + String account = req.getParameter("account"); + String amount = req.getParameter("Amount"); + if ("deposit".equals(req.getParameter("actionType"))) + accountServices.deposit(account, Float.parseFloat(amount)); + else + accountServices.withdraw(account, Float.parseFloat(amount)); + } + } catch (Exception e) { + throw new ServletException("accountTransaction " + e.getMessage(), e); + } + + } + + private void createAccount(HttpServletRequest pReq, HttpServletResponse pResp, AccountService accountServices) throws ServletException { + try { + CustomerProfileData customerProfileData = AccountFactory.INSTANCE.createCustomerProfileData(); + customerProfileData.setFirstName(pReq.getParameter("firstName")); + customerProfileData.setLastName(pReq.getParameter("lastName")); + customerProfileData.setAddress(pReq.getParameter("address")); + customerProfileData.setEmail(pReq.getParameter("email")); + customerProfileData.setLoginID(pReq.getParameter("loginID")); + customerProfileData.setPassword(pReq.getParameter("password")); + + CustomerProfileData resp = accountServices.createAccount(customerProfileData, "savings".equals(pReq.getParameter("savings")), "checkings" + .equals(pReq.getParameter("checkings"))); + LoginServlet.login(resp.getLoginID(), resp.getPassword()); + + } catch (IOException e) { + throw new ServletException(e); + } + + } +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java new file mode 100644 index 0000000000..886f42a778 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java @@ -0,0 +1,91 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.webclient.ui; + +import java.io.IOException; +import java.rmi.RemoteException; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.osoa.sca.CurrentModuleContext; +import org.osoa.sca.ModuleContext; + +import bigbank.webclient.services.profile.LoginService; + +public class LoginServlet extends HttpServlet { + + public void init(ServletConfig pCfg) throws ServletException { + + } + + public void doPost(HttpServletRequest pReq, HttpServletResponse pResp) throws ServletException { + + if ("logout".equals(pReq.getParameter("logout")) || "logoutHIDDEN".equals(pReq.getParameter("logoutHIDDEN"))) { + HttpSession sess = pReq.getSession(); + if (sess != null) + sess.invalidate(); + try { + pResp.sendRedirect("login.html"); + } catch (IOException e) { + + e.printStackTrace(); + throw new ServletException(e); + } + + } else { + + String login = pReq.getParameter("login"); + String password = pReq.getParameter("password"); + try { + int resp = login(login, password); + if (resp == LoginService.SUCCESS) { + + pResp.sendRedirect("summary.jsp"); + } else { + + pResp.sendRedirect("login.html"); + } + } catch (IOException e) { + throw new ServletException(e); + } + } + } + + static int login(final String login, final String password) throws ServletException { + + ModuleContext moduleContext = CurrentModuleContext.getContext(); + LoginService loginMgr = (LoginService) moduleContext.locateService("LoginServiceComponent"); + + if (loginMgr == null) { + throw new ServletException("LoginManager not found"); + } + + try { + return loginMgr.login(login, password); + } catch (RemoteException e) { + + throw new ServletException(e); + } + + } + +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/resources/sca.module b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/resources/sca.module new file mode 100644 index 0000000000..05e3859587 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/resources/sca.module @@ -0,0 +1,51 @@ + + + + + + + + + + + + AccountServiceComponent + ProfileServiceComponent + + + + + + + Anonymous + + + + + + + AccountService + + + + + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/resources/sca.subsystem b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/resources/sca.subsystem new file mode 100644 index 0000000000..c0b66ca4e7 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/resources/sca.subsystem @@ -0,0 +1,27 @@ + + + + + + + sample-bigbank-account-subsystem/sample-bigbank-account/AccountService + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/resources/wsdl/AccountService.wsdl b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/resources/wsdl/AccountService.wsdl new file mode 100644 index 0000000000..c44b826440 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/resources/wsdl/AccountService.wsdl @@ -0,0 +1,392 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/CustomerProfile.jsp b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/CustomerProfile.jsp new file mode 100644 index 0000000000..6fc0484056 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/CustomerProfile.jsp @@ -0,0 +1,97 @@ + +<%-- + Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --%> + + + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + +<%-- LINK href="theme/Master.css" rel="stylesheet" type="text/css" --%> +BigBank- Customer Account + +

Customer Account
+
+

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


+

+ + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/WEB-INF/bigbank-tags.tld b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/WEB-INF/bigbank-tags.tld new file mode 100644 index 0000000000..36554640cd --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/WEB-INF/bigbank-tags.tld @@ -0,0 +1,91 @@ + + + + 1.0 + 2.0 + BigBank Tags + Tag library containing BigBank tags + + service + bigbank.webclient.tags.sca.ServiceTag + JSP + Places a reference to an SCA Service in the page context + + id + true + false + + + name + true + false + + + + login + bigbank.webclient.tags.sca.LoginBarrierTag + JSP + Redirects if user is not logged in + + profile + true + false + + + url + true + false + + + + + accountStatus + bigbank.webclient.tags.account.AccountStatusTag + JSP + Accesses and iterates the account service + + id + true + false + + + accountService + true + false + + + profileService + true + false + + + + stockStatus + bigbank.webclient.tags.account.StockStatusTag + JSP + Accesses and iterates the stocks + + id + true + false + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..3b4c735a62 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,44 @@ + + + + + Tuscany Bigbank Web UI sample + + login.html + + + + LoginServlet + bigbank.webclient.ui.LoginServlet + 1 + + + FormServlet + bigbank.webclient.ui.FormServlet + 0 + + + + LoginServlet + /loginAction/* + + + FormServlet + /FormServlet/* + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/accountTransaction.jsp b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/accountTransaction.jsp new file mode 100644 index 0000000000..4188b70b71 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/accountTransaction.jsp @@ -0,0 +1,47 @@ + +<%-- + Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --%> + + + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +BigBank - <%=request.getParameter("account") %> + + +

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

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


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

+ + +

+ + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/purchaseStock.jsp b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/purchaseStock.jsp new file mode 100644 index 0000000000..b0838a9a81 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/purchaseStock.jsp @@ -0,0 +1,56 @@ + +<%-- + Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --%> + + + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + +BigBank- Stock purchase + +

Stock purchase
+
+

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


+

+ + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/stockSale.jsp b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/stockSale.jsp new file mode 100644 index 0000000000..de4c438ffb --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/stockSale.jsp @@ -0,0 +1,53 @@ + +<%-- + Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --%> + + + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + +BigBank- Stock sale + +

Stock sale
+
+

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


+

+ + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/summary.jsp b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/summary.jsp new file mode 100644 index 0000000000..263ab9e1ac --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/main/webapp/summary.jsp @@ -0,0 +1,136 @@ +<%-- + Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --%> + + <%@ page import="com.bigbank.account.AccountSummary" %> + <%@ page import="com.bigbank.account.StockSummary" %> + <%@ page session="true" %> + <%@ page autoFlush="true" %> +<%@ taglib uri="/WEB-INF/bigbank-tags.tld" prefix="sca" %> + + + + + BigBank Account Summary + + + + Account Information for +
+ + + +    +
+ + + + + + + + + + + + + + + + + + + + + +
Account Balance
+ + + + + + + + + + +
+ + + +
+
+ Stocks:     
+
+ + + + + + + + <%-- spacer --%> + + + + + + <%-- spacer --%> + + + +
+
+ + + + <%-- spacer --%> + + + + + + + + <%-- spacer --%> + + + + +
SymbolQuantityPurchase Date  Purchase PriceCurrent PriceCompany NameToday HighToday Low   <%-- sell button --%>
+ + + + + +    + + + + + + + + + +    +
+ +
+ + + + +
diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/test/java/bigbank/webclient/client/TestAccountService.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/test/java/bigbank/webclient/client/TestAccountService.java new file mode 100644 index 0000000000..5dbb56865f --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/test/java/bigbank/webclient/client/TestAccountService.java @@ -0,0 +1,52 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.webclient.client; + +import java.util.List; + +import org.apache.tuscany.core.client.TuscanyRuntime; +import org.osoa.sca.CurrentModuleContext; +import org.osoa.sca.ModuleContext; +import org.osoa.sca.SCA; + +import com.bigbank.account.AccountReport; +import com.bigbank.account.AccountService; + + +public class TestAccountService extends SCA { + + public void start() { + } + + public void stop() { + } + + public static void main(String[] args) throws Exception { + TuscanyRuntime tuscany = new TuscanyRuntime("bigbank.webclient.testclient", null); + tuscany.start(); + ModuleContext moduleContext = CurrentModuleContext.getContext(); + + AccountService accountService = (AccountService) moduleContext.locateService("AccountServiceComponent"); + + AccountReport report = accountService.getAccountReport(12345); + List summaries = report.getAccountSummaries(); + + System.out.println("retrieved " + summaries.size() + " summaries"); + + tuscany.stop(); + } +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/test/java/bigbank/webclient/client/TestLoginService.java b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/test/java/bigbank/webclient/client/TestLoginService.java new file mode 100644 index 0000000000..4d2f10a706 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient/src/test/java/bigbank/webclient/client/TestLoginService.java @@ -0,0 +1,50 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package bigbank.webclient.client; + +import org.osoa.sca.CurrentModuleContext; +import org.osoa.sca.ModuleContext; +import org.osoa.sca.SCA; + +import org.apache.tuscany.core.client.TuscanyRuntime; + +import bigbank.webclient.services.profile.LoginService; + + +public class TestLoginService extends SCA { + + public void start() { + } + + public void stop() { + } + + public static void main(String[] args) throws Exception { + + + TuscanyRuntime tuscany = new TuscanyRuntime("bigbank.webclient.testclient", null); + tuscany.start(); + ModuleContext moduleContext = CurrentModuleContext.getContext(); + LoginService loginService = (LoginService) + moduleContext.locateService("LoginServiceComponent"); + + if (loginService.login("test", "password") == LoginService.SUCCESS) + System.out.println("Success"); + else + System.out.println("Failure"); + } +} diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/build.xml b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/build.xml new file mode 100644 index 0000000000..4057778754 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/build.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/pom.xml b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/pom.xml new file mode 100644 index 0000000000..47dacad2b2 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/pom.xml @@ -0,0 +1,93 @@ + + + + 4.0.0 + org.apache.tuscany.sampleapps + tuscany-sampleapps + pom + Tuscany Scenario Samples + incubating-M1 + + + 2.0 + + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + ibiblio + ibiblio + http://www.ibiblio.org/maven2 + + + incubating-M1 + incubating-M1 + http://people.apache.org/~jsdelfino/maven2 + + + + + bigbank + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + + + + src/main/java + + **/*.componentType + + + + src/main/resources + + + + + + src/test/java + + **/*.componentType + + + + src/test/resources + + + install + + + + diff --git a/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/readme.htm b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/readme.htm new file mode 100644 index 0000000000..d701d89aa0 --- /dev/null +++ b/sca-java-1.x/tags/java-M1-20060518/java/sampleapps/readme.htm @@ -0,0 +1,20 @@ + + + + + + + + + Tuscany Hello World Web Sample + + + + + + +Please see +bigbank/readme.htm + + + -- cgit v1.2.3