01: /*
02: * $Id: DefaultLender.java 10789 2008-02-12 20:04:43Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10:
11: package org.mule.example.loanbroker.lender;
12:
13: import org.mule.example.loanbroker.bank.Bank;
14: import org.mule.example.loanbroker.messages.CreditProfile;
15: import org.mule.example.loanbroker.messages.LoanBrokerQuoteRequest;
16:
17: /**
18: * <code>DefaultLenderService</code> is responsible for contacting the relivant
19: * banks depending on the amount of the loan
20: */
21: public class DefaultLender implements LenderService {
22: /**
23: * Sets the list of lenders on the LoanBrokerQuoteRequest and returns it.
24: */
25: public void setLenderList(LoanBrokerQuoteRequest request) {
26: Bank[] lenders = getLenders(
27: request.getCreditProfile(),
28: new Double(request.getCustomerRequest().getLoanAmount()));
29: request.setLenders(lenders);
30: }
31:
32: /**
33: * @inheritDocs
34: */
35: public Bank[] getLenders(CreditProfile creditProfile,
36: Double loanAmount) {
37: // TODO Add creditProfile info. to the logic below.
38: // TODO Look up the existing banks from the config/registry instead of
39: // creating them programatically here.
40: Bank[] lenders;
41: if ((loanAmount.doubleValue() >= 20000)) {
42: lenders = new Bank[2];
43: lenders[0] = new Bank("Bank1");
44: lenders[1] = new Bank("Bank2");
45: } else if (((loanAmount.doubleValue() >= 10000) && (loanAmount
46: .doubleValue() <= 19999))) {
47: lenders = new Bank[2];
48: lenders[0] = new Bank("Bank3");
49: lenders[1] = new Bank("Bank4");
50: } else {
51: lenders = new Bank[1];
52: lenders[0] = new Bank("Bank5");
53: }
54:
55: return lenders;
56: }
57: }
|