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