1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
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 | |
|
23 | |
|
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 | |
} |