1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.routing.outbound; |
12 | |
|
13 | |
import org.mule.api.MuleEvent; |
14 | |
import org.mule.util.StringUtils; |
15 | |
|
16 | |
import java.util.ArrayList; |
17 | |
import java.util.Arrays; |
18 | |
import java.util.Collections; |
19 | |
import java.util.List; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | 0 | public class StaticRecipientList extends AbstractRecipientList |
30 | |
{ |
31 | |
public static final String RECIPIENTS_PROPERTY = "recipients"; |
32 | |
public static final String RECIPIENT_DELIMITER = ","; |
33 | |
|
34 | 0 | private volatile List recipients = Collections.EMPTY_LIST; |
35 | |
|
36 | |
protected List getRecipients(MuleEvent event) |
37 | |
{ |
38 | 0 | Object msgRecipients = event.getMessage().removeProperty(RECIPIENTS_PROPERTY); |
39 | |
|
40 | 0 | if (msgRecipients == null) |
41 | |
{ |
42 | 0 | return recipients; |
43 | |
} |
44 | 0 | else if (msgRecipients instanceof String) |
45 | |
{ |
46 | 0 | return Arrays.asList(StringUtils.splitAndTrim(msgRecipients.toString(), this.getListDelimiter())); |
47 | |
} |
48 | 0 | else if (msgRecipients instanceof List) |
49 | |
{ |
50 | 0 | return new ArrayList((List) msgRecipients); |
51 | |
} |
52 | |
else |
53 | |
{ |
54 | 0 | logger.warn("Recipients on message are neither String nor List but: " + msgRecipients.getClass()); |
55 | 0 | return Collections.EMPTY_LIST; |
56 | |
} |
57 | |
} |
58 | |
|
59 | |
public List getRecipients() |
60 | |
{ |
61 | 0 | return recipients; |
62 | |
} |
63 | |
|
64 | |
public void setRecipients(List recipients) |
65 | |
{ |
66 | 0 | if (recipients != null) |
67 | |
{ |
68 | 0 | this.recipients = new ArrayList(recipients); |
69 | |
} |
70 | |
else |
71 | |
{ |
72 | 0 | this.recipients = Collections.EMPTY_LIST; |
73 | |
} |
74 | 0 | } |
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
protected String getListDelimiter() |
83 | |
{ |
84 | 0 | return RECIPIENT_DELIMITER; |
85 | |
} |
86 | |
|
87 | |
} |