Coverage Report - org.mule.routing.requestreply.ReplyToMessageProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
ReplyToMessageProcessor
0%
0/17
0%
0/16
3
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.routing.requestreply;
 8  
 
 9  
 import org.apache.commons.lang.BooleanUtils;
 10  
 import org.mule.api.MuleEvent;
 11  
 import org.mule.api.MuleException;
 12  
 import org.mule.api.config.MuleProperties;
 13  
 import org.mule.api.processor.InterceptingMessageProcessor;
 14  
 import org.mule.api.transport.ReplyToHandler;
 15  
 import org.mule.construct.SimpleFlowConstruct;
 16  
 import org.mule.processor.AbstractInterceptingMessageProcessor;
 17  
 
 18  
 /**
 19  
  * Send message according to reply to property
 20  
  */
 21  0
 public class ReplyToMessageProcessor extends AbstractInterceptingMessageProcessor
 22  
         implements InterceptingMessageProcessor
 23  
 {
 24  
 
 25  
     public MuleEvent process(MuleEvent event) throws MuleException
 26  
     {
 27  
         MuleEvent resultEvent;
 28  
         //In config is service then this is executed by ServiceInternalMessageProcessor
 29  0
         if (event.getFlowConstruct() instanceof SimpleFlowConstruct)
 30  
         {
 31  0
             Object replyTo = event.getReplyToDestination();
 32  0
             ReplyToHandler replyToHandler = event.getReplyToHandler();
 33  
             // Do not propagate REPLY_TO
 34  0
             event.getMessage().setReplyTo(null);
 35  
 
 36  0
             resultEvent = processNext(event);
 37  
 
 38  
             // Allow components to stop processing of the ReplyTo property (e.g. CXF)
 39  0
             final String replyToStop = resultEvent.getMessage().getInvocationProperty(
 40  
                     MuleProperties.MULE_REPLY_TO_STOP_PROPERTY);
 41  0
             if (resultEvent != null && !BooleanUtils.toBoolean(replyToStop))
 42  
             {
 43  0
                 processReplyTo(event, resultEvent, replyToHandler, replyTo);
 44  
             }
 45  0
         }
 46  
         else
 47  
         {
 48  0
             resultEvent = processNext(event);
 49  
         }
 50  0
         return resultEvent;
 51  
     }
 52  
 
 53  
     protected void processReplyTo(MuleEvent event,
 54  
                                   MuleEvent result,
 55  
                                   ReplyToHandler replyToHandler,
 56  
                                   Object replyTo) throws MuleException
 57  
     {
 58  0
         if (result != null && replyToHandler != null)
 59  
         {
 60  0
             String requestor = result.getMessage().getOutboundProperty(
 61  
                     MuleProperties.MULE_REPLY_TO_REQUESTOR_PROPERTY);
 62  0
             if ((requestor != null && !requestor.equals(event.getFlowConstruct().getName()))
 63  
                     || requestor == null)
 64  
             {
 65  0
                 replyToHandler.processReplyTo(event, result.getMessage(), replyTo);
 66  
             }
 67  
         }
 68  0
     }
 69  
 
 70  
 }