You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2006/09/19 00:10:06 UTC

svn commit: r447594 [1/2] - in /incubator/tuscany/sandbox/rfeng/samples: ./ mortage/ mortage/src/ mortage/src/main/ mortage/src/main/java/ mortage/src/main/java/mortage/ mortage/src/main/resources/ mortage/src/main/resources/META-INF/ mortage/src/main/...

Author: rfeng
Date: Mon Sep 18 15:10:05 2006
New Revision: 447594

URL: http://svn.apache.org/viewvc?view=rev&rev=447594
Log:
Add the sample mortage application into my sandbox

Added:
    incubator/tuscany/sandbox/rfeng/samples/
    incubator/tuscany/sandbox/rfeng/samples/mortage/
    incubator/tuscany/sandbox/rfeng/samples/mortage/pom.xml   (with props)
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/CreditCheck.java   (with props)
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/CreditCheckImpl.java   (with props)
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/Customer.java   (with props)
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/InterestRateQuote.java   (with props)
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/InterestRateQuoteImpl.java   (with props)
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/LoanApplication.java   (with props)
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/LoanApplicationImpl.java   (with props)
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageCalculator.java   (with props)
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageCalculatorImpl.java   (with props)
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageClient.java   (with props)
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/RiskAssessment.java   (with props)
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/RiskAssessmentImpl.java   (with props)
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/resources/
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/resources/META-INF/
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/resources/META-INF/LICENSE.txt   (with props)
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/resources/META-INF/NOTICE
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/resources/META-INF/sca/
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/resources/META-INF/sca/default.scdl
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/test/
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/test/java/
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/test/java/mortage/
    incubator/tuscany/sandbox/rfeng/samples/mortage/src/test/java/mortage/MortageClientTestCase.java   (with props)

Added: incubator/tuscany/sandbox/rfeng/samples/mortage/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/samples/mortage/pom.xml?view=auto&rev=447594
==============================================================================
--- incubator/tuscany/sandbox/rfeng/samples/mortage/pom.xml (added)
+++ incubator/tuscany/sandbox/rfeng/samples/mortage/pom.xml Mon Sep 18 15:10:05 2006
@@ -0,0 +1,59 @@
+<?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>
+    <parent>
+        <groupId>org.apache.tuscany.samples.sca</groupId>
+        <artifactId>parent</artifactId>
+        <version>1.0-incubator-M2-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>sample-mortage</artifactId>
+    <packaging>jar</packaging>
+    <name>Tuscany Mortage Sample</name>
+    <description>A sample Mortage application made of several SCA components wired together.</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osoa</groupId>
+            <artifactId>sca-api-r0.95</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>test</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <mainClass>mortage.MortageClient</mainClass>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/CreditCheck.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/CreditCheck.java?view=auto&rev=447594
==============================================================================
--- incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/CreditCheck.java (added)
+++ incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/CreditCheck.java Mon Sep 18 15:10:05 2006
@@ -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 mortage;
+
+public interface CreditCheck {
+    int getCreditScore(String ssn);
+}

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/CreditCheck.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/CreditCheck.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/CreditCheckImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/CreditCheckImpl.java?view=auto&rev=447594
==============================================================================
--- incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/CreditCheckImpl.java (added)
+++ incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/CreditCheckImpl.java Mon Sep 18 15:10:05 2006
@@ -0,0 +1,39 @@
+/*
+ * 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 mortage;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the CreditReportService service
+ */
+@Scope("MODULE")
+public class CreditCheckImpl implements CreditCheck {
+
+    public int getCreditScore(String ssn) {
+        return (int) (700 + (Math.random() - 0.5) * 100);
+    }
+
+    public static void main(String[] args) {
+        CreditCheck creditCheck = new CreditCheckImpl();
+        for (int i = 0; i < 3; i++) {
+            System.out.println(creditCheck.getCreditScore("111-22-3333"));
+        }
+    }
+}

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/CreditCheckImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/CreditCheckImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/Customer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/Customer.java?view=auto&rev=447594
==============================================================================
--- incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/Customer.java (added)
+++ incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/Customer.java Mon Sep 18 15:10:05 2006
@@ -0,0 +1,62 @@
+/*
+ * 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 mortage;
+
+/**
+ *
+ */
+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;
+    }
+}

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/Customer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/Customer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/InterestRateQuote.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/InterestRateQuote.java?view=auto&rev=447594
==============================================================================
--- incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/InterestRateQuote.java (added)
+++ incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/InterestRateQuote.java Mon Sep 18 15:10:05 2006
@@ -0,0 +1,5 @@
+package mortage;
+
+public interface InterestRateQuote {
+    public float getRate(String state, double loanAmount, int termInYears);
+}

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/InterestRateQuote.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/InterestRateQuote.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/InterestRateQuoteImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/InterestRateQuoteImpl.java?view=auto&rev=447594
==============================================================================
--- incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/InterestRateQuoteImpl.java (added)
+++ incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/InterestRateQuoteImpl.java Mon Sep 18 15:10:05 2006
@@ -0,0 +1,10 @@
+package mortage;
+
+public class InterestRateQuoteImpl implements InterestRateQuote {
+    public float getRate(String state, double loanAmount, int termInYears) {
+        if (termInYears == 5)
+            return 5.5f;
+        else
+            return 6.5f;
+    }
+}

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/InterestRateQuoteImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/InterestRateQuoteImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/LoanApplication.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/LoanApplication.java?view=auto&rev=447594
==============================================================================
--- incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/LoanApplication.java (added)
+++ incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/LoanApplication.java Mon Sep 18 15:10:05 2006
@@ -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 mortage;
+
+/**
+ *
+ */
+public interface LoanApplication {
+    public boolean approve(Customer customer, double loanAmount, int years);
+}

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/LoanApplication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/LoanApplication.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/LoanApplicationImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/LoanApplicationImpl.java?view=auto&rev=447594
==============================================================================
--- incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/LoanApplicationImpl.java (added)
+++ incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/LoanApplicationImpl.java Mon Sep 18 15:10:05 2006
@@ -0,0 +1,78 @@
+/*
+ * 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 mortage;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Calculator service.
+ */
+@Scope("MODULE")
+public class LoanApplicationImpl implements LoanApplication {
+
+    private CreditCheck creditCheck;
+
+    private RiskAssessment riskAssessment;
+    private MortageCalculator mortageCalculator;
+    private InterestRateQuote interestRateQuote;
+
+    private int minimumCreditScore = 650;
+
+    @Reference
+    public void setCreditCheck(CreditCheck creditCheck) {
+        this.creditCheck = creditCheck;
+    }
+
+    @Reference
+    public void setRiskAssessment(RiskAssessment riskAssessment) {
+        this.riskAssessment = riskAssessment;
+    }
+
+    public boolean approve(Customer customer, double loanAmount, int years) {
+        int score = creditCheck.getCreditScore(customer.getSsn());
+        if (score < minimumCreditScore)
+            return false;
+        
+        float rate = interestRateQuote.getRate(customer.getState(), loanAmount, years);
+        double monthlyPayment = mortageCalculator.getMonthlyPayment(loanAmount, years, rate);
+        double ratio = monthlyPayment/customer.getMonthlyIncome();
+        return riskAssessment.assess(score, ratio);
+    }
+
+    @Property(name = "minimumCreditScore")
+    public void setMinimumCreditScore(int minimumCreditScore) {
+        this.minimumCreditScore = minimumCreditScore;
+    }
+
+    public static void main(String[] args) {
+    }
+
+    @Reference
+    public void setInterestRateQuote(InterestRateQuote interestRateQuote) {
+        this.interestRateQuote = interestRateQuote;
+    }
+
+    @Reference
+    public void setMortageCalculator(MortageCalculator mortageCalculator) {
+        this.mortageCalculator = mortageCalculator;
+    }
+
+}

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/LoanApplicationImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/LoanApplicationImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageCalculator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageCalculator.java?view=auto&rev=447594
==============================================================================
--- incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageCalculator.java (added)
+++ incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageCalculator.java Mon Sep 18 15:10:05 2006
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package mortage;
+
+/**
+ * The Calculator service interface.
+ */
+public interface MortageCalculator {
+    public double getMonthlyPayment(double principal, int years, float interestRate);
+}

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageCalculator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageCalculator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageCalculatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageCalculatorImpl.java?view=auto&rev=447594
==============================================================================
--- incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageCalculatorImpl.java (added)
+++ incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageCalculatorImpl.java Mon Sep 18 15:10:05 2006
@@ -0,0 +1,41 @@
+/*
+ * 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 mortage;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * An implementation of the Calculator service.
+ */
+@Scope("MODULE")
+public class MortageCalculatorImpl implements MortageCalculator {
+
+    public double getMonthlyPayment(double principal, int years, float interestRate) {
+        double monthlyRate = interestRate / 12 / 100;
+        double p = Math.pow(1 + monthlyRate, years * 12);
+        double q = p / (p - 1);
+        double monthlyPayment = principal * monthlyRate * q;
+        return monthlyPayment;
+    }
+
+    public static void main(String[] args) {
+        System.out.println(new MortageCalculatorImpl().getMonthlyPayment(300000d, 30, 3.5f));
+    }
+
+}

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageCalculatorImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageCalculatorImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageClient.java?view=auto&rev=447594
==============================================================================
--- incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageClient.java (added)
+++ incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageClient.java Mon Sep 18 15:10:05 2006
@@ -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 mortage;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * This client program shows how to create an SCA runtime, start it, locate the Calculator service and invoke it.
+ */
+public class MortageClient {
+    public static void main(String[] args) throws Exception {
+
+        CompositeContext context = CurrentCompositeContext.getContext();
+        LoanApplication loanApplication = context.locateService(LoanApplication.class, "LoanApplicationComponent");
+        
+        Customer customer = new Customer();
+        customer.setSsn("111-22-3333");
+        customer.setFirstName("John");
+        customer.setLastName("Smith");
+        customer.setMonthlyIncome(5000.0d);
+        customer.setState("CA");
+        
+        loanApplication.approve(customer, 200000d, 30);
+    }
+}

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/MortageClient.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/RiskAssessment.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/RiskAssessment.java?view=auto&rev=447594
==============================================================================
--- incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/RiskAssessment.java (added)
+++ incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/RiskAssessment.java Mon Sep 18 15:10:05 2006
@@ -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 mortage;
+
+/**
+ *
+ */
+public interface RiskAssessment {
+    public boolean assess(int creditScore, double ratio);
+}

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/RiskAssessment.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/RiskAssessment.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/RiskAssessmentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/RiskAssessmentImpl.java?view=auto&rev=447594
==============================================================================
--- incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/RiskAssessmentImpl.java (added)
+++ incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/RiskAssessmentImpl.java Mon Sep 18 15:10:05 2006
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package mortage;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * 
+ */
+@Scope("MODULE")
+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;
+    }
+}

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/RiskAssessmentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/rfeng/samples/mortage/src/main/java/mortage/RiskAssessmentImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org