Coverage Report - org.mule.routing.outbound.StaticRecipientList
 
Classes in this File Line Coverage Branch Coverage Complexity
StaticRecipientList
53%
9/17
25%
2/8
2.75
 
 1  
 /*
 2  
  * $Id: StaticRecipientList.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.routing.outbound;
 12  
 
 13  
 import org.mule.umo.UMOMessage;
 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  
  * <code>StaticRecipientList</code> is used to dispatch a single event to multiple
 23  
  * recipients over the same transport. The recipient endpoints for this router can be
 24  
  * configured statically on the router itself.
 25  
  */
 26  
 
 27  4
 public class StaticRecipientList extends AbstractRecipientList
 28  
 {
 29  
     public static final String RECIPIENTS_PROPERTY = "recipients";
 30  
     public static final String RECIPIENT_DELIMITER = ",";
 31  
 
 32  4
     private volatile List recipients = Collections.EMPTY_LIST;
 33  
 
 34  
     protected List getRecipients(UMOMessage message)
 35  
     {
 36  6
         Object msgRecipients = message.removeProperty(RECIPIENTS_PROPERTY);
 37  
 
 38  6
         if (msgRecipients == null)
 39  
         {
 40  6
             return recipients;
 41  
         }
 42  0
         else if (msgRecipients instanceof String)
 43  
         {
 44  0
             return Arrays.asList(StringUtils.splitAndTrim(msgRecipients.toString(), this.getListDelimiter()));
 45  
         }
 46  0
         else if (msgRecipients instanceof List)
 47  
         {
 48  0
             return new ArrayList((List) msgRecipients);
 49  
         }
 50  
         else
 51  
         {
 52  0
             logger.warn("Recipients on message are neither String nor List but: " + msgRecipients.getClass());
 53  0
             return Collections.EMPTY_LIST;
 54  
         }
 55  
     }
 56  
 
 57  
     public List getRecipients()
 58  
     {
 59  6
         return recipients;
 60  
     }
 61  
 
 62  
     public void setRecipients(List recipients)
 63  
     {
 64  4
         if (recipients != null)
 65  
         {
 66  4
             this.recipients = new ArrayList(recipients);
 67  
         }
 68  
         else
 69  
         {
 70  0
             this.recipients = Collections.EMPTY_LIST;
 71  
         }
 72  4
     }
 73  
 
 74  
     /**
 75  
      * Overloading classes can change the delimiter used to separate entries in the
 76  
      * recipient list. By default a ',' is used.
 77  
      * 
 78  
      * @return The list delimiter to use
 79  
      */
 80  
     protected String getListDelimiter()
 81  
     {
 82  0
         return RECIPIENT_DELIMITER;
 83  
     }
 84  
 
 85  
 
 86  
 
 87  
 }