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