1 /* 2 * $Id: CreditAgencyGateway.java 20321 2010-11-24 15:21:24Z dfeist $ 3 * -------------------------------------------------------------------------------------- 4 * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.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 package org.mule.example.loanbroker.esb; 11 12 import org.mule.example.loanbroker.credit.CreditAgencyService; 13 import org.mule.example.loanbroker.messages.CreditProfile; 14 import org.mule.example.loanbroker.messages.LoanBrokerQuoteRequest; 15 16 /** 17 * This service is the gateway used to pass requests to the credit agency service. For the sake of the example we've added 18 * some complexity here. 19 * 1) We use a _component binding_ to bind the {@link org.mule.example.loanbroker.credit.CreditAgencyService} to the remote 20 * CreditAgencyService EJB instance. 21 * 2) The argument passed into this interface binding is {@link org.mule.example.loanbroker.messages.Customer} but the EJB instance 22 * needs only a String (name) and Integer (ssn). Also the EJB service returns an XML message, but we convert it to a {@link org.mule.example.loanbroker.messages.CreditProfile} 23 * object. We demonstrate how to perform argument transalations by configuring transformers and response-transformers on an endpoint. 24 */ 25 public class CreditAgencyGateway 26 { 27 //This interface is bound to an endpoint (known as an interface binding). When the getCreditProfile() method is invoked, the call 28 //will be made to a remote service. 29 private CreditAgencyService creditAgencyService; 30 31 public LoanBrokerQuoteRequest process(LoanBrokerQuoteRequest request) 32 { 33 CreditProfile cp = creditAgencyService.getCreditProfile(request.getCustomerRequest().getCustomer()); 34 request.setCreditProfile(cp); 35 return request; 36 } 37 38 public CreditAgencyService getCreditAgencyService() 39 { 40 return creditAgencyService; 41 } 42 43 public void setCreditAgencyService(CreditAgencyService creditAgencyService) 44 { 45 this.creditAgencyService = creditAgencyService; 46 } 47 }