summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval')
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/README60
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/build.xml66
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/credit_composite.jpgbin0 -> 73610 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/credit_composite.pngbin0 -> 51153 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/loan_approval.jpgbin0 -> 162536 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/loan_approval.pngbin0 -> 58247 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly0.jpgbin0 -> 145053 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly0.pngbin0 -> 93773 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly1.jpgbin0 -> 181317 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly1.pngbin0 -> 113404 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly2.jpgbin0 -> 180240 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly2.pngbin0 -> 106656 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_composite.jpgbin0 -> 343699 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_composite.pngbin0 -> 288351 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_diagrams.docbin0 -> 81920 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package1.jpgbin0 -> 181031 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package1.pngbin0 -> 34939 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package2.jpgbin0 -> 110930 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package2.pngbin0 -> 58993 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_scenario.jpgbin0 -> 225690 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_scenario.pngbin0 -> 106791 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/mortgage_assembly.pngbin0 -> 106656 bytes
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/pom.xml83
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheck.java29
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheckImpl.java34
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/java/mortgage/Customer.java76
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuote.java23
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuoteImpl.java42
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApproval.java27
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApprovalImpl.java84
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculator.java29
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculatorImpl.java38
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageClient.java44
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessment.java27
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessmentImpl.java38
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/resources/Mortgage.composite48
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/resources/Mortgage1.composite57
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.componentType27
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.js25
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/resources/wsdl/credit.wsdl81
-rw-r--r--sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/test/java/mortgage/MortgageClientTestCase.java56
41 files changed, 994 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/README b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/README
new file mode 100644
index 0000000000..dbf3829a20
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/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.5/demos/mortgage-loanapproval/build.xml b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/build.xml
new file mode 100644
index 0000000000..9a0a83bf1d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/build.xml
@@ -0,0 +1,66 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project name="mortgage-loanapproval" default="compile">
+ <property name="test.class" value="mortgage.MortgageClient" />
+ <property name="test.jar" value="demo-mortgage-loanapproval.jar" />
+
+ <target name="init">
+ <mkdir dir="target/classes" />
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java" destdir="target/classes" debug="on" source="1.5" target="1.5">
+ <classpath>
+ <pathelement location="../../lib/tuscany-sca-manifest.jar" />
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources" />
+ </copy>
+ <jar destfile="target/${test.jar}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${test.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="run-classes">
+ <java classname="${test.class}" fork="true">
+ <classpath>
+ <pathelement path="target/classes" />
+ <pathelement location="../../lib/tuscany-sca-manifest.jar" />
+ </classpath>
+ </java>
+ </target>
+
+ <target name="run">
+ <java classname="${test.class}" fork="true">
+ <classpath>
+ <pathelement path="target/${test.jar}" />
+ <pathelement location="../../lib/tuscany-sca-manifest.jar" />
+ </classpath>
+ </java>
+ </target>
+
+ <target name="clean">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target" />
+ </delete>
+ </target>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/credit_composite.jpg b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/credit_composite.jpg
new file mode 100644
index 0000000000..e28ed63cfb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/credit_composite.jpg
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/credit_composite.png b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/credit_composite.png
new file mode 100644
index 0000000000..0bfce0078d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/credit_composite.png
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/loan_approval.jpg b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/loan_approval.jpg
new file mode 100644
index 0000000000..3f00557c7f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/loan_approval.jpg
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/loan_approval.png b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/loan_approval.png
new file mode 100644
index 0000000000..9d5f829fe5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/loan_approval.png
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly0.jpg b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly0.jpg
new file mode 100644
index 0000000000..515b6ecde7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly0.jpg
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly0.png b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly0.png
new file mode 100644
index 0000000000..4b815a4b82
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly0.png
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly1.jpg b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly1.jpg
new file mode 100644
index 0000000000..01a7c55a14
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly1.jpg
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly1.png b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly1.png
new file mode 100644
index 0000000000..07422c4f45
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly1.png
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly2.jpg b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly2.jpg
new file mode 100644
index 0000000000..992c048684
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly2.jpg
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly2.png b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly2.png
new file mode 100644
index 0000000000..4667956ed0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_assembly2.png
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_composite.jpg b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_composite.jpg
new file mode 100644
index 0000000000..5021f6a317
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_composite.jpg
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_composite.png b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_composite.png
new file mode 100644
index 0000000000..1398c50ded
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_composite.png
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_diagrams.doc b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_diagrams.doc
new file mode 100644
index 0000000000..32a0b72907
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_diagrams.doc
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package1.jpg b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package1.jpg
new file mode 100644
index 0000000000..e91c5f1bbd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package1.jpg
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package1.png b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package1.png
new file mode 100644
index 0000000000..db304a4c28
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package1.png
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package2.jpg b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package2.jpg
new file mode 100644
index 0000000000..e8c2865e4a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package2.jpg
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package2.png b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package2.png
new file mode 100644
index 0000000000..502e538e94
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_package2.png
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_scenario.jpg b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_scenario.jpg
new file mode 100644
index 0000000000..fccf2e35c3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_scenario.jpg
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_scenario.png b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_scenario.png
new file mode 100644
index 0000000000..b8f42ad318
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/doc/mortgage_scenario.png
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/mortgage_assembly.png b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/mortgage_assembly.png
new file mode 100644
index 0000000000..4667956ed0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/mortgage_assembly.png
Binary files differ
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/pom.xml b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/pom.xml
new file mode 100644
index 0000000000..3f74134cbe
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-demos</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>demo-mortgage-loanapproval</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany SCA Demo Mortgage Loan Approval</name>
+ <description>A sample Mortgage application made of several SCA components wired together.</description>
+
+ <properties>
+ <property name="tuscanyVersion">1.5-SNAPSHOT</property>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-script</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>mortgage.MortgageClient</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheck.java b/sca-java-1.x/branches/sca-java-1.5/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.5/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.5/demos/mortgage-loanapproval/src/main/java/mortgage/CreditCheckImpl.java b/sca-java-1.x/branches/sca-java-1.5/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.5/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.5/demos/mortgage-loanapproval/src/main/java/mortgage/Customer.java b/sca-java-1.x/branches/sca-java-1.5/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.5/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.5/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuote.java b/sca-java-1.x/branches/sca-java-1.5/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.5/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.5/demos/mortgage-loanapproval/src/main/java/mortgage/InterestRateQuoteImpl.java b/sca-java-1.x/branches/sca-java-1.5/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.5/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.5/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApproval.java b/sca-java-1.x/branches/sca-java-1.5/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.5/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.5/demos/mortgage-loanapproval/src/main/java/mortgage/LoanApprovalImpl.java b/sca-java-1.x/branches/sca-java-1.5/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.5/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.5/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculator.java b/sca-java-1.x/branches/sca-java-1.5/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.5/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.5/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageCalculatorImpl.java b/sca-java-1.x/branches/sca-java-1.5/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.5/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.5/demos/mortgage-loanapproval/src/main/java/mortgage/MortgageClient.java b/sca-java-1.x/branches/sca-java-1.5/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.5/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.5/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessment.java b/sca-java-1.x/branches/sca-java-1.5/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.5/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.5/demos/mortgage-loanapproval/src/main/java/mortgage/RiskAssessmentImpl.java b/sca-java-1.x/branches/sca-java-1.5/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.5/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.5/demos/mortgage-loanapproval/src/main/resources/Mortgage.composite b/sca-java-1.x/branches/sca-java-1.5/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.5/demos/mortgage-loanapproval/src/main/resources/Mortgage.composite
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://mortgage" name="MortgageComposite">
+
+ <component name="LoanApprovalComponent">
+ <implementation.java class="mortgage.LoanApprovalImpl" />
+ <property name="minimumCreditScore">600</property>
+ <reference name="creditCheck" target="CreditCheckComponent" />
+ <reference name="interestRateQuote" target="InterestRateQuoteComponent" />
+ <reference name="riskAssessment" target="RiskAssessmentComponent" />
+ <reference name="mortgageCalculator" target="MortgageCalculatorComponent" />
+ </component>
+
+ <component name="CreditCheckComponent">
+ <implementation.java class="mortgage.CreditCheckImpl" />
+ </component>
+
+ <component name="InterestRateQuoteComponent">
+ <implementation.java class="mortgage.InterestRateQuoteImpl" />
+ </component>
+
+ <component name="RiskAssessmentComponent">
+ <implementation.java class="mortgage.RiskAssessmentImpl" />
+ </component>
+
+ <component name="MortgageCalculatorComponent">
+ <implementation.java class="mortgage.MortgageCalculatorImpl" />
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/resources/Mortgage1.composite b/sca-java-1.x/branches/sca-java-1.5/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.5/demos/mortgage-loanapproval/src/main/resources/Mortgage1.composite
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://mortgage" name="MortgageComposite">
+
+ <component name="LoanApprovalComponent">
+ <implementation.java class="mortgage.LoanApprovalImpl" />
+ <property name="minimumCreditScore">600</property>
+ <reference name="creditCheck">
+ <binding.ws wsdlElement="http://credit#wsdl.port(CreditCheckService/CreditCheckSoapPort)" />
+ </reference>
+ <reference name="interestRateQuote" target="InterestRateQuoteComponent" />
+ <reference name="riskAssessment" target="RiskAssessmentComponent" />
+ <reference name="mortgageCalculator" target="MortgageCalculatorJSComponent" />
+ </component>
+
+ <component name="CreditCheckComponent">
+ <implementation.java class="mortgage.CreditCheckImpl" />
+ </component>
+
+ <component name="InterestRateQuoteComponent">
+ <implementation.java class="mortgage.InterestRateQuoteImpl" />
+ </component>
+
+ <component name="RiskAssessmentComponent">
+ <implementation.java class="mortgage.RiskAssessmentImpl" />
+ </component>
+
+ <component name="MortgageCalculatorJSComponent">
+ <tuscany:implementation.script script="MortgageCalculator.js" />
+ </component>
+
+ <!--
+ <reference name="CreditCheckReference" promote="LoanApprovalComponent/creditCheck">
+ <interface.java interface="mortgage.CreditCheck" />
+ <binding.ws wsdlElement="http://credit#wsdl.port(CreditCheckService/CreditCheckSoapPort)" />
+ </reference>
+ -->
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.componentType b/sca-java-1.x/branches/sca-java-1.5/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.5/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.componentType
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="MortgageCalculatorService">
+ <interface.java interface="mortgage.MortgageCalculator"/>
+ </service>
+
+</componentType>
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/main/resources/MortgageCalculator.js b/sca-java-1.x/branches/sca-java-1.5/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.5/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.5/demos/mortgage-loanapproval/src/main/resources/wsdl/credit.wsdl b/sca-java-1.x/branches/sca-java-1.5/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.5/demos/mortgage-loanapproval/src/main/resources/wsdl/credit.wsdl
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions targetNamespace="http://credit" xmlns:tns="http://credit" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="credit">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://credit" xmlns:tns="http://credit"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="getCreditScore">
+ <complexType>
+ <sequence>
+ <element name="ssn" type="xsd:string" />
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getCreditScoreResponse">
+ <complexType>
+ <sequence>
+ <element name="score" type="xsd:int" />
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getCreditScoreRequest">
+ <wsdl:part element="tns:getCreditScore" name="inputMsg" />
+ </wsdl:message>
+
+ <wsdl:message name="getCreditScoreResponse">
+ <wsdl:part element="tns:getCreditScoreResponse" name="outputMsg" />
+ </wsdl:message>
+
+
+ <wsdl:portType name="CreditCheck">
+ <wsdl:operation name="getCreditScore">
+ <wsdl:input message="tns:getCreditScoreRequest" name="getCreditScoreRequest" />
+ <wsdl:output message="tns:getCreditScoreResponse" name="getCreditScoreResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="CreditCheckSoapBinding" type="tns:CreditCheck">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="getCreditScore">
+ <wsdlsoap:operation soapAction="" />
+ <wsdl:input name="getCreditScoreRequest">
+ <wsdlsoap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output name="getCreditScoreResponse">
+ <wsdlsoap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="CreditCheckService">
+ <wsdl:port binding="tns:CreditCheckSoapBinding" name="CreditCheckSoapPort">
+ <wsdlsoap:address location="http://localhost:8085/CreditCheckServiceComponent" />
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/branches/sca-java-1.5/demos/mortgage-loanapproval/src/test/java/mortgage/MortgageClientTestCase.java b/sca-java-1.x/branches/sca-java-1.5/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.5/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);
+ }
+}