Coverage Report - org.mule.examples.loanbroker.transformers.SetLendersAsRecipients
 
Classes in this File Line Coverage Branch Coverage Complexity
SetLendersAsRecipients
0%
0/12
0%
0/8
2
 
 1  
 /*
 2  
  * $Id: SetLendersAsRecipients.java 10498 2008-01-24 10:19:31Z 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.transformers;
 12  
 
 13  
 import org.mule.examples.loanbroker.bank.Bank;
 14  
 import org.mule.examples.loanbroker.messages.LoanBrokerQuoteRequest;
 15  
 import org.mule.routing.outbound.StaticRecipientList;
 16  
 import org.mule.transformers.AbstractEventAwareTransformer;
 17  
 import org.mule.umo.UMOEventContext;
 18  
 import org.mule.umo.UMOMessage;
 19  
 import org.mule.umo.transformer.TransformerException;
 20  
 
 21  
 /**
 22  
  * Set the Recipient List property on the LoanBrokerQuoteRequest message based on the
 23  
  * list of banks in LoanBrokerQuoteRequest.getLenders()
 24  
  */
 25  
 public class SetLendersAsRecipients extends AbstractEventAwareTransformer
 26  
 {
 27  
 
 28  
     public SetLendersAsRecipients()
 29  0
     {
 30  0
         this.registerSourceType(LoanBrokerQuoteRequest.class);
 31  0
         this.setReturnClass(UMOMessage.class);
 32  0
     }
 33  
 
 34  
     public Object transform(Object src, String encoding, UMOEventContext context) throws TransformerException
 35  
     {
 36  0
         Bank[] lenders = ((LoanBrokerQuoteRequest)src).getLenders();
 37  
 
 38  0
         String recipients = "";
 39  0
         for (int i = 0; i < lenders.length; i++)
 40  
         {
 41  0
             if (i > 0) recipients += ",";
 42  0
             recipients += lenders[i].getEndpoint();
 43  
         }
 44  
 
 45  0
         UMOMessage msg = context.getMessage();
 46  0
         context.getMessage().setProperty(StaticRecipientList.RECIPIENTS_PROPERTY, recipients);
 47  0
         return msg;
 48  
     }
 49  
 
 50  
 }