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/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 +++ 30 files changed, 2559 insertions(+) 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 (limited to 'sca-java-1.x/tags/java-M1-20060518/java/sampleapps/bigbank/webclient') 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"); + } +} -- cgit v1.2.3