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