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.transformers;
8   
9   import org.mule.api.transformer.TransformerException;
10  import org.mule.example.loanbroker.messages.LoanBrokerQuoteRequest;
11  import org.mule.transformer.AbstractTransformer;
12  import org.mule.transformer.types.DataTypeFactory;
13  
14  /**
15   * Extracts the customer information from the request into an array of arguments used
16   * to invoke the Credit Agency MuleSession bean
17   */
18  public class LoanQuoteRequestToCreditProfileArgs extends AbstractTransformer
19  {
20  
21      public LoanQuoteRequestToCreditProfileArgs()
22      {
23          registerSourceType(DataTypeFactory.create(LoanBrokerQuoteRequest.class));
24          setReturnDataType(DataTypeFactory.create(Object[].class));
25      }
26  
27      @Override
28      public Object doTransform(Object src, String encoding) throws TransformerException
29      {
30          LoanBrokerQuoteRequest request = (LoanBrokerQuoteRequest)src;
31          Object[] args = new Object[2];
32          args[0] = request.getCustomerRequest().getCustomer().getName();
33          args[1] = new Integer(request.getCustomerRequest().getCustomer().getSsn());
34          return args;
35      }
36  
37  }