View Javadoc

1   /*
2    * $Id: SynchronousLoanBroker.java 7976 2007-08-21 14:26:13Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.examples.loanbroker.esn;
12  
13  import org.mule.examples.loanbroker.DefaultLoanBroker;
14  import org.mule.examples.loanbroker.LoanBrokerException;
15  import org.mule.examples.loanbroker.credit.CreditAgencyService;
16  import org.mule.examples.loanbroker.messages.CreditProfile;
17  import org.mule.examples.loanbroker.messages.CustomerQuoteRequest;
18  import org.mule.examples.loanbroker.messages.LoanBrokerQuoteRequest;
19  
20  /**
21   * <code>SyncLoanBroker</code> is a synchronous Loan Broker that makes the calls to
22   * various components through the event context synchronously.
23   */
24  public class SynchronousLoanBroker extends DefaultLoanBroker
25  {
26      //A proxy for this object gets injected via the <nested-router> elemet configured on this service.
27      //The proxy will then call out to an endpoint and return the result.
28      //The transformers configured on the endpoint control how data is marshalled into and out of the call.
29      private CreditAgencyService creditAgency;
30  
31      public Object getLoanQuote(CustomerQuoteRequest request) throws LoanBrokerException
32      {
33          super.getLoanQuote(request);
34          LoanBrokerQuoteRequest bqr = new LoanBrokerQuoteRequest();
35          bqr.setCustomerRequest(request);
36  
37          //This calls out to the CreditAgency service (see above)
38          CreditProfile cp = creditAgency.getCreditProfile(request.getCustomer());
39          bqr.setCreditProfile(cp);
40  
41          return bqr;
42      }
43  
44      public CreditAgencyService getCreditAgency()
45      {
46          return creditAgency;
47      }
48  
49      public void setCreditAgency(CreditAgencyService creditAgency)
50      {
51          this.creditAgency = creditAgency;
52      }
53  }