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