1 10 11 package org.mule.samples.loanbroker; 12 13 import org.apache.commons.logging.Log; 14 import org.apache.commons.logging.LogFactory; 15 import org.mule.samples.loanbroker.service.LoanBroker; 16 17 import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger; 18 19 23 public class AsyncLoanBroker implements LoanBroker 24 { 25 28 protected static Log logger = LogFactory.getLog(AsyncLoanBroker.class); 29 30 private static final AtomicInteger quotes = new AtomicInteger(0); 31 private static final AtomicInteger requests = new AtomicInteger(0); 32 33 public AsyncLoanBroker() 34 { 35 super(); 36 } 37 38 public BankQuoteRequest getLoanQuote(LoanRequest request) 39 { 40 logger.info("\nClient " + request.getCustomer().getName() + " with ssn= " 41 + request.getCustomer().getSsn() + " requests a loan of amount= " 42 + request.getLoanAmount() + " for " + request.getLoanDuration() + " months"); 43 BankQuoteRequest bqr = new BankQuoteRequest(); 44 bqr.setLoanRequest(request); 45 return bqr; 46 } 47 48 public Object receiveQuote(LoanQuote quote) 49 { 50 System.out.println("Quote " + incQuotes() + " received: " + quote); 51 return null; 52 } 53 54 public int incQuotes() 55 { 56 return quotes.incrementAndGet(); 57 } 58 59 public int incRequests() 60 { 61 return requests.incrementAndGet(); 62 } 63 64 } 65 | Popular Tags |