1 10 11 package org.mule.routing.outbound; 12 13 import java.util.Collections ; 14 import java.util.List ; 15 16 import org.mule.umo.UMOMessage; 17 import org.mule.util.StringUtils; 18 19 import edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList; 20 21 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 CopyOnWriteArrayList recipients = new CopyOnWriteArrayList(); 33 34 protected List getRecipients(UMOMessage 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 new CopyOnWriteArrayList(StringUtils.splitAndTrim(msgRecipients.toString(), 45 getListDelimiter())); 46 } 47 else if (msgRecipients instanceof List ) 48 { 49 return new CopyOnWriteArrayList((List )msgRecipients); 50 } 51 else 52 { 53 logger.warn("Recipients on message are neither String nor List but: " + msgRecipients.getClass()); 54 return Collections.EMPTY_LIST; 55 } 56 } 57 58 public List getRecipients() 59 { 60 return recipients; 61 } 62 63 public void setRecipients(List recipients) 64 { 65 if (recipients != null) 66 { 67 this.recipients = new CopyOnWriteArrayList(recipients); 68 } 69 else 70 { 71 this.recipients = null; 72 } 73 } 74 75 81 protected String getListDelimiter() 82 { 83 return RECIPIENT_DELIMITER; 84 } 85 86 } 87 | Popular Tags |