Coverage Report - org.mule.processor.chain.DefaultMessageProcessorChain
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultMessageProcessorChain
0%
0/20
0%
0/8
0
 
 1  
 /*
 2  
  * $Id: DefaultMessageProcessorChain.java 20320 2010-11-24 15:03:31Z dfeist $
 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.processor.chain;
 12  
 
 13  
 import org.mule.DefaultMuleEvent;
 14  
 import org.mule.OptimizedRequestContext;
 15  
 import org.mule.api.MuleEvent;
 16  
 import org.mule.api.MuleException;
 17  
 import org.mule.api.construct.FlowConstruct;
 18  
 import org.mule.api.endpoint.OutboundEndpoint;
 19  
 import org.mule.api.processor.MessageProcessor;
 20  
 import org.mule.construct.SimpleFlowConstruct;
 21  
 
 22  
 import java.util.Arrays;
 23  
 import java.util.List;
 24  
 
 25  
 public class DefaultMessageProcessorChain extends AbstractMessageProcessorChain
 26  
 {
 27  
 
 28  
     public DefaultMessageProcessorChain(List<MessageProcessor> processors)
 29  
     {
 30  0
         super(null, processors);
 31  0
     }
 32  
 
 33  
     public DefaultMessageProcessorChain(MessageProcessor... processors)
 34  
     {
 35  0
         super(null, Arrays.asList(processors));
 36  0
     }
 37  
 
 38  
     public DefaultMessageProcessorChain(String name, List<MessageProcessor> processors)
 39  
     {
 40  0
         super(name, processors);
 41  0
     }
 42  
 
 43  
     public DefaultMessageProcessorChain(String name, MessageProcessor... processors)
 44  
     {
 45  0
         super(name, Arrays.asList(processors));
 46  0
     }
 47  
 
 48  
     protected MuleEvent doProcess(MuleEvent event) throws MuleException
 49  
     {
 50  0
         FlowConstruct flowConstruct = event.getFlowConstruct();
 51  0
         MuleEvent currentEvent = event;
 52  
         MuleEvent resultEvent;
 53  0
         for (MessageProcessor processor : processors)
 54  
         {
 55  
             // If the next message processor is an outbound router then create
 56  
             // outbound event
 57  0
             if (processor instanceof OutboundEndpoint)
 58  
             {
 59  0
                 currentEvent = new DefaultMuleEvent(currentEvent.getMessage(), (OutboundEndpoint) processor,
 60  
                     currentEvent.getSession());
 61  
             }
 62  0
             resultEvent = processor.process(currentEvent);
 63  0
             if (resultEvent != null)
 64  
             {
 65  0
                 currentEvent = resultEvent;
 66  
             }
 67  
             else
 68  
             {
 69  0
                 if (flowConstruct instanceof SimpleFlowConstruct)
 70  
                 {
 71  0
                     currentEvent = OptimizedRequestContext.criticalSetEvent(currentEvent);
 72  
                 }
 73  
                 else
 74  
                 {
 75  0
                     return null;
 76  
                 }
 77  
             }
 78  
         }
 79  0
         return currentEvent;
 80  
     }
 81  
 
 82  
 }