Coverage Report - org.mule.routing.outbound.ExpressionMessageSplitter
 
Classes in this File Line Coverage Branch Coverage Complexity
ExpressionMessageSplitter
0%
0/28
0%
0/4
0
 
 1  
 /*
 2  
  * $Id: ExpressionMessageSplitter.java 20321 2010-11-24 15:21:24Z dfeist $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.api.MuleMessage;
 14  
 import org.mule.api.lifecycle.InitialisationException;
 15  
 import org.mule.expression.ExpressionConfig;
 16  
 
 17  
 import java.util.ArrayList;
 18  
 import java.util.List;
 19  
 
 20  
 /**
 21  
  * Evaluates a single expression and adds the results of the expression as individual message parts.
 22  
  */
 23  
 public class ExpressionMessageSplitter extends AbstractRoundRobinMessageSplitter
 24  
 {
 25  0
     protected ExpressionConfig config = new ExpressionConfig();
 26  
 
 27  
     public ExpressionMessageSplitter()
 28  
     {
 29  0
         super();
 30  0
     }
 31  
 
 32  
     public ExpressionMessageSplitter(ExpressionConfig config)
 33  0
     {
 34  0
         this.config = config;
 35  0
         setEvaluator(config.getEvaluator());
 36  0
     }
 37  
 
 38  
     public String getCustomEvaluator()
 39  
     {
 40  0
         return config.getCustomEvaluator();
 41  
     }
 42  
 
 43  
     public void setCustomEvaluator(String customEvaluator)
 44  
     {
 45  0
         config.setCustomEvaluator(customEvaluator);
 46  0
     }
 47  
 
 48  
     public String getEvaluator()
 49  
     {
 50  0
         return config.getEvaluator();
 51  
     }
 52  
 
 53  
     public void setEvaluator(String evaluator)
 54  
     {
 55  
         //Switch to XPath node since we want the Dom nodes not the value of the node
 56  0
         if (evaluator.equals("xpath"))
 57  
         {
 58  0
             evaluator = "xpath-node";
 59  
         }
 60  0
         config.setEvaluator(evaluator);
 61  0
     }
 62  
 
 63  
     public String getExpression()
 64  
     {
 65  0
         return config.getExpression();
 66  
     }
 67  
 
 68  
     public void setExpression(String expression)
 69  
     {
 70  0
         this.config.setExpression(expression);
 71  0
     }
 72  
 
 73  
     @Override
 74  
     public void initialise() throws InitialisationException
 75  
     {
 76  0
         super.initialise();
 77  0
         config.validate(expressionManager);
 78  0
     }
 79  
 
 80  
     @Override
 81  
     protected List splitMessage(MuleMessage message)
 82  
     {
 83  0
         List results = new ArrayList(4);
 84  0
         Object result = muleContext.getExpressionManager().evaluate(config.getFullExpression(expressionManager), message);
 85  0
         if (result instanceof List)
 86  
         {
 87  0
             results.addAll((List)result);
 88  
         }
 89  
         else
 90  
         {
 91  0
             results.add(result);
 92  0
             logger.warn("Splitter only returned a single result. If this is not expected, please check your split expression");
 93  
         }
 94  0
         return results;
 95  
     }
 96  
 }