From 07b7dfd1a70ba222b899d9813f8c449dbf3b785f Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:07:28 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835124 13f79535-47bb-0310-9956-ffa450edef68 --- .../demos/mortgage-loanapproval/DISCLAIMER | 8 + .../demos/mortgage-loanapproval/LICENSE | 205 +++++++++++++++++++++ .../demos/mortgage-loanapproval/NOTICE | 6 + .../demos/mortgage-loanapproval/README | 60 ++++++ .../demos/mortgage-loanapproval/build.xml | 66 +++++++ .../mortgage-loanapproval/doc/credit_composite.jpg | Bin 0 -> 73610 bytes .../mortgage-loanapproval/doc/credit_composite.png | Bin 0 -> 51153 bytes .../mortgage-loanapproval/doc/loan_approval.jpg | Bin 0 -> 162536 bytes .../mortgage-loanapproval/doc/loan_approval.png | Bin 0 -> 58247 bytes .../doc/mortgage_assembly0.jpg | Bin 0 -> 145053 bytes .../doc/mortgage_assembly0.png | Bin 0 -> 93773 bytes .../doc/mortgage_assembly1.jpg | Bin 0 -> 181317 bytes .../doc/mortgage_assembly1.png | Bin 0 -> 113404 bytes .../doc/mortgage_assembly2.jpg | Bin 0 -> 180240 bytes .../doc/mortgage_assembly2.png | Bin 0 -> 106656 bytes .../doc/mortgage_composite.jpg | Bin 0 -> 343699 bytes .../doc/mortgage_composite.png | Bin 0 -> 288351 bytes .../doc/mortgage_diagrams.doc | Bin 0 -> 2278400 bytes .../doc/mortgage_package1.jpg | Bin 0 -> 181031 bytes .../doc/mortgage_package1.png | Bin 0 -> 34939 bytes .../doc/mortgage_package2.jpg | Bin 0 -> 110930 bytes .../doc/mortgage_package2.png | Bin 0 -> 58993 bytes .../doc/mortgage_scenario.jpg | Bin 0 -> 225690 bytes .../doc/mortgage_scenario.png | Bin 0 -> 106791 bytes .../mortgage-loanapproval/mortgage_assembly.png | Bin 0 -> 106656 bytes .../demos/mortgage-loanapproval/pom.xml | 83 +++++++++ .../src/main/java/mortgage/CreditCheck.java | 29 +++ .../src/main/java/mortgage/CreditCheckImpl.java | 34 ++++ .../src/main/java/mortgage/Customer.java | 76 ++++++++ .../src/main/java/mortgage/InterestRateQuote.java | 23 +++ .../main/java/mortgage/InterestRateQuoteImpl.java | 42 +++++ .../src/main/java/mortgage/LoanApproval.java | 27 +++ .../src/main/java/mortgage/LoanApprovalImpl.java | 84 +++++++++ .../src/main/java/mortgage/MortgageCalculator.java | 29 +++ .../main/java/mortgage/MortgageCalculatorImpl.java | 38 ++++ .../src/main/java/mortgage/MortgageClient.java | 44 +++++ .../src/main/java/mortgage/RiskAssessment.java | 27 +++ .../src/main/java/mortgage/RiskAssessmentImpl.java | 38 ++++ .../src/main/resources/Mortgage.composite | 48 +++++ .../src/main/resources/Mortgage1.composite | 57 ++++++ .../resources/MortgageCalculator.componentType | 27 +++ .../src/main/resources/MortgageCalculator.js | 25 +++ .../src/main/resources/wsdl/credit.wsdl | 81 ++++++++ .../test/java/mortgage/MortgageClientTestCase.java | 56 ++++++ 44 files changed, 1213 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/DISCLAIMER create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/LICENSE create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/NOTICE create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/README create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/build.xml create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/credit_composite.jpg create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/credit_composite.png create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/loan_approval.jpg create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/loan_approval.png create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly0.jpg create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly0.png create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly1.jpg create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly1.png create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly2.jpg create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly2.png create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_composite.jpg create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_composite.png create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_diagrams.doc create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package1.jpg create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package1.png create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package2.jpg create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package2.png create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_scenario.jpg create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_scenario.png create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/mortgage_assembly.png create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheck.java create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheckImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/Customer.java create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuote.java create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuoteImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApproval.java create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApprovalImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculator.java create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculatorImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageClient.java create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessment.java create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessmentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/Mortgage.composite create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/Mortgage1.composite create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.componentType create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.js create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/wsdl/credit.wsdl create mode 100644 sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/test/java/mortgage/MortgageClientTestCase.java (limited to 'sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval') diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/DISCLAIMER b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/DISCLAIMER new file mode 100644 index 0000000000..d68a410903 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/DISCLAIMER @@ -0,0 +1,8 @@ +Apache Tuscany is an effort undergoing incubation at The Apache Software +Foundation (ASF), sponsored by the Apache 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. + diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/LICENSE b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/LICENSE @@ -0,0 +1,205 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/NOTICE b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/README b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/README new file mode 100644 index 0000000000..dbf3829a20 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/README @@ -0,0 +1,60 @@ +Mortgage Loan Approval Demo +=========================== + +This demo was used as an example in the java developer journal article: http://jdj.sys-con.com/read/325183.htm. + +The demo consists of two modules: + +mortgage-loanapproval: provides the business logic for loan approval. +mortgage-creditcheck: handles credit check requests. This is a java component exposed as a webservice running on the embedded Tomcat. + +Please check mortgage_assembly.png file that is located in this directory for a high level view of the demo. + +Here is what happens when you run the demo. A loan approval request for customer with id 111-222-3333 +gets initiated when mortgage-loanapproval application is run. Depending on what the 'imaginary' credit + status of this person is, the loan gets approved or diapproved. + +You would need two command windows to run mortgage loan approval composite. The order in which the +applications are run is important. Run mortgage-creditcheck first since mortgage-loanapproval is dependent on +it's service. + +In the first command window +--------------------------- +1) go to mortgage-creditcheck directory +2) ant compile +3) ant run +You should see the following displayed: +Buildfile: build.xml + +run: + [java] Starting the CreditCheck Service... + [java] 14-Jan-2008 14:14:20 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:8085/CreditCheckServiceC +omponent + [java] Press Enter to Exit... + +In the second command window +---------------------------- +1) go to mortgage-loanapproval directory +2) ant compile +3) ant run + +If the loan is approved, you will see the following displayed in the command screen where +mortgage-loanapproval is run: + +Buildfile: build.xml +run: + [java] Interest rate for a 30-year loan of $200000.0 in CA: 6.5% + [java] Approved: John Smith[111-22-3333] + +If the loan is disapproved, you will see the following displayed in the command screen where +mortgage-loanapproval is run: + +Buildfile: build.xml +run: + [java] Credit score for 111-22-3333: 708 + [java] Interest rate for a 30-year loan of $200000.0 in CA: 6.5% + [java] Debt/Income ratio 0.2528272093971861 is too high. + [java] Rejected: John Smith[111-22-3333] + diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/build.xml b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/build.xml new file mode 100644 index 0000000000..9a0a83bf1d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/build.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/credit_composite.jpg b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/credit_composite.jpg new file mode 100644 index 0000000000..e28ed63cfb Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/credit_composite.jpg differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/credit_composite.png b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/credit_composite.png new file mode 100644 index 0000000000..0bfce0078d Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/credit_composite.png differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/loan_approval.jpg b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/loan_approval.jpg new file mode 100644 index 0000000000..3f00557c7f Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/loan_approval.jpg differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/loan_approval.png b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/loan_approval.png new file mode 100644 index 0000000000..9d5f829fe5 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/loan_approval.png differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly0.jpg b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly0.jpg new file mode 100644 index 0000000000..515b6ecde7 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly0.jpg differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly0.png b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly0.png new file mode 100644 index 0000000000..4b815a4b82 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly0.png differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly1.jpg b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly1.jpg new file mode 100644 index 0000000000..01a7c55a14 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly1.jpg differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly1.png b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly1.png new file mode 100644 index 0000000000..07422c4f45 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly1.png differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly2.jpg b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly2.jpg new file mode 100644 index 0000000000..992c048684 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly2.jpg differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly2.png b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly2.png new file mode 100644 index 0000000000..4667956ed0 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_assembly2.png differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_composite.jpg b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_composite.jpg new file mode 100644 index 0000000000..5021f6a317 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_composite.jpg differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_composite.png b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_composite.png new file mode 100644 index 0000000000..1398c50ded Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_composite.png differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_diagrams.doc b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_diagrams.doc new file mode 100644 index 0000000000..00d45e1084 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_diagrams.doc differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package1.jpg b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package1.jpg new file mode 100644 index 0000000000..e91c5f1bbd Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package1.jpg differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package1.png b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package1.png new file mode 100644 index 0000000000..db304a4c28 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package1.png differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package2.jpg b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package2.jpg new file mode 100644 index 0000000000..e8c2865e4a Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package2.jpg differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package2.png b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package2.png new file mode 100644 index 0000000000..502e538e94 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_package2.png differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_scenario.jpg b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_scenario.jpg new file mode 100644 index 0000000000..fccf2e35c3 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_scenario.jpg differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_scenario.png b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_scenario.png new file mode 100644 index 0000000000..b8f42ad318 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/doc/mortgage_scenario.png differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/mortgage_assembly.png b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/mortgage_assembly.png new file mode 100644 index 0000000000..4667956ed0 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/mortgage_assembly.png differ diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/pom.xml b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/pom.xml new file mode 100644 index 0000000000..9c4a07a9c0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-demos + 1.1-incubating-SNAPSHOT + ../pom.xml + + demo-mortgage-loanapproval + jar + Apache Tuscany SCA Mortgage Loan Approval Demo + A sample Mortgage application made of several SCA components wired together. + + + 1.1-incubating-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.1-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.1-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.1-incubating-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-implementation-script + 1.1-incubating-SNAPSHOT + runtime + + + + + + install + ${artifactId} + + + org.apache.maven.plugins + maven-jar-plugin + + + + mortgage.MortgageClient + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheck.java b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheck.java new file mode 100644 index 0000000000..c5787b7819 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheck.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Remotable; + +/** + * CreditCheck interface + */ +@Remotable +public interface CreditCheck { + int getCreditScore(String ssn); +} diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheckImpl.java b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheckImpl.java new file mode 100644 index 0000000000..dc803d9688 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheckImpl.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Service; + +/** + * A pojo implementation of the CreditCheck service + */ +@Service(CreditCheck.class) +public class CreditCheckImpl implements CreditCheck { + + public int getCreditScore(String ssn) { + int score = (int)(700 + (Math.random() - 0.5) * 100); + System.out.println("Credit score for " + ssn + ": " + score); + return score; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/Customer.java b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/Customer.java new file mode 100644 index 0000000000..66a486d516 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/Customer.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package mortgage; + +/** + * A simple Customer object + */ +public class Customer { + private String ssn; + private String firstName; + private String lastName; + private double monthlyIncome; + private String state; + + public double getMonthlyIncome() { + return monthlyIncome; + } + + public void setMonthlyIncome(double monthlyIncome) { + this.monthlyIncome = monthlyIncome; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getSsn() { + return ssn; + } + + public void setSsn(String ssn) { + this.ssn = ssn; + } + + @Override + public String toString() { + return firstName + " " + lastName + "[" + ssn + "]"; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuote.java b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuote.java new file mode 100644 index 0000000000..b5bafeb204 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuote.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +public interface InterestRateQuote { + public float getRate(String state, double loanAmount, int termInYears); +} diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuoteImpl.java b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuoteImpl.java new file mode 100644 index 0000000000..8c642667f1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuoteImpl.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Service; + +@Service(InterestRateQuote.class) +public class InterestRateQuoteImpl implements InterestRateQuote { + public float getRate(String state, double loanAmount, int termInYears) { + float rate = 6.0f; + if (termInYears == 5) { + rate = 5.5f; + } else { + rate = 6.5f; + } + System.out.println("Interest rate for a " + termInYears + + "-year loan of $" + + loanAmount + + " in " + + state + + ": " + + rate + + "%"); + return rate; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApproval.java b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApproval.java new file mode 100644 index 0000000000..dcdad18496 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApproval.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package mortgage; + +/** + * Loan Approval interface + */ +public interface LoanApproval { + public boolean approve(Customer customer, double loanAmount, int years); +} diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApprovalImpl.java b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApprovalImpl.java new file mode 100644 index 0000000000..40bfdc4a1d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApprovalImpl.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * An implementation of the LoanApproval service. + */ +@Service(LoanApproval.class) +// Service declaration +public class LoanApprovalImpl implements LoanApproval { + private CreditCheck[] creditCheck; + private MortgageCalculator mortgageCalculator; + private InterestRateQuote interestRateQuote; + + // Reference declaration using a protected or public field + @Reference + public RiskAssessment riskAssessment; + + private int minimumCreditScore = 650; + + // Property declaration using a setter method + @Property(name = "minimumCreditScore") + public void setMinimumCreditScore(int minimumCreditScore) { + this.minimumCreditScore = minimumCreditScore; + } + + // Reference declaration using a setter method + @Reference + public void setCreditCheck(CreditCheck[] creditCheck) { + this.creditCheck = creditCheck; + } + + @Reference + public void setInterestRateQuote(InterestRateQuote interestRateQuote) { + this.interestRateQuote = interestRateQuote; + } + + @Reference + public void setMortgageCalculator(MortgageCalculator mortgageCalculator) { + this.mortgageCalculator = mortgageCalculator; + } + + public boolean approve(Customer customer, double loanAmount, int years) { + int score = 0; + for (int i = 0; i < creditCheck.length; i++) { + score += creditCheck[i].getCreditScore(customer.getSsn()); + } + if (score != 0) { + score = score / creditCheck.length; + } + if (score < minimumCreditScore) { + System.err.println("Credit score " + score + " is below the minimum " + minimumCreditScore + "."); + return false; + } + float rate = interestRateQuote.getRate(customer.getState(), loanAmount, years); + double monthlyPayment = mortgageCalculator.getMonthlyPayment(loanAmount, years, rate); + double ratio = monthlyPayment / customer.getMonthlyIncome(); + boolean approved = riskAssessment.assess(score, ratio); + if (!approved) { + System.err.println("Debt/Income ratio " + ratio + " is too high."); + } + return approved; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculator.java b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculator.java new file mode 100644 index 0000000000..cacd8694de --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculator.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Remotable; + +/** + * The Mortgage Calculator service interface. + */ +@Remotable +public interface MortgageCalculator { + public double getMonthlyPayment(double principal, int years, float interestRate); +} diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculatorImpl.java b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculatorImpl.java new file mode 100644 index 0000000000..015f1bae98 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculatorImpl.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.osoa.sca.annotations.Service; + +/** + * An implementation of the Calculator service. + */ +@Service(MortgageCalculator.class) +public class MortgageCalculatorImpl implements MortgageCalculator { + + public double getMonthlyPayment(double principal, int years, float interestRate) { + double monthlyRate = interestRate / 12.0 / 100.0; + double p = Math.pow(1 + monthlyRate, years * 12); + double q = p / (p - 1); + double monthlyPayment = principal * monthlyRate * q; + System.out.println("Monthly payment for a " + years + "-year loan of $" + principal + ": " + monthlyPayment); + return monthlyPayment; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageClient.java b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageClient.java new file mode 100644 index 0000000000..d69f0a1163 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageClient.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This client program to invoke the Mortgage LoanApproval service + */ +public class MortgageClient { + public static void main(String[] args) throws Exception { + + SCADomain domain = SCADomain.newInstance("Mortgage1.composite"); + LoanApproval loanApplication = domain.getService(LoanApproval.class, "LoanApprovalComponent"); + + // Create the customer + Customer customer = new Customer(); + customer.setSsn("111-22-3333"); + customer.setFirstName("John"); + customer.setLastName("Smith"); + customer.setMonthlyIncome(5000.0d); + customer.setState("CA"); + + // Invoke the service + boolean result = loanApplication.approve(customer, 200000d, 30); + System.out.println((result ? "Approved: " : "Rejected: ") + customer); + } +} diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessment.java b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessment.java new file mode 100644 index 0000000000..23c9589e85 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessment.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package mortgage; + +/** + * Risk Assessment interface + */ +public interface RiskAssessment { + public boolean assess(int creditScore, double ratio); +} diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessmentImpl.java b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessmentImpl.java new file mode 100644 index 0000000000..c2116366ec --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessmentImpl.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package mortgage; + +import org.osoa.sca.annotations.Service; + +/** + * A pojo implementation of RiskAssessment service + */ +@Service(RiskAssessment.class) +public class RiskAssessmentImpl implements RiskAssessment { + public boolean assess(int creditScore, double ratio) { + if (creditScore >= 750) { + return ratio < 0.35; + } else if (creditScore >= 700) { + return ratio < 0.30; + } else { + return ratio < 0.25; + } + } +} diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/Mortgage.composite b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/Mortgage.composite new file mode 100644 index 0000000000..d1128b9907 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/Mortgage.composite @@ -0,0 +1,48 @@ + + + + + + + 600 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/Mortgage1.composite b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/Mortgage1.composite new file mode 100644 index 0000000000..4cad6c7223 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/Mortgage1.composite @@ -0,0 +1,57 @@ + + + + + + + 600 + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.componentType b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.componentType new file mode 100644 index 0000000000..bf7b10e0f7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.componentType @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.js b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.js new file mode 100644 index 0000000000..b25af1d039 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.js @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +function getMonthlyPayment(principal, years, interestRate) { + var monthlyRate = interestRate / 12.0 / 100.0; + var p = Math.pow(1 + monthlyRate, years * 12); + var q = p / (p - 1); + var monthlyPayment = principal * monthlyRate * q; + return monthlyPayment; +} diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/wsdl/credit.wsdl b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/wsdl/credit.wsdl new file mode 100644 index 0000000000..9c2acc96d3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/main/resources/wsdl/credit.wsdl @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/test/java/mortgage/MortgageClientTestCase.java b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/test/java/mortgage/MortgageClientTestCase.java new file mode 100644 index 0000000000..285cc72515 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.1/demos/mortgage-loanapproval/src/test/java/mortgage/MortgageClientTestCase.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mortgage; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This shows how to test the Calculator service component. + */ +public class MortgageClientTestCase extends TestCase { + private SCADomain domain; + private LoanApproval loanApproval; + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("Mortgage.composite"); + loanApproval = domain.getService(LoanApproval.class, "LoanApprovalComponent"); + } + + @Override + protected void tearDown() throws Exception { + if (domain != null) { + domain.close(); + } + } + + public void testApprove() throws Exception { + Customer customer = new Customer(); + customer.setSsn("111-22-3333"); + customer.setFirstName("John"); + customer.setLastName("Smith"); + customer.setMonthlyIncome(5000.0d); + customer.setState("CA"); + + boolean approved = loanApproval.approve(customer, 200000d, 30); + System.out.println((approved ? "Approved: " : "Rejected: ") + customer); + } +} -- cgit v1.2.3