Coverage Report - org.mule.config.spring.parsers.specific.ResponseDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
ResponseDefinitionParser
0%
0/5
N/A
0
ResponseDefinitionParser$EndpointResponseMessageProcessorChainFactoryBean
0%
0/10
0%
0/6
0
 
 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.config.spring.parsers.specific;
 8  
 
 9  
 import org.mule.api.processor.MessageProcessor;
 10  
 import org.mule.api.processor.MessageProcessorBuilder;
 11  
 import org.mule.config.spring.factories.MessageProcessorChainFactoryBean;
 12  
 import org.mule.config.spring.factories.ResponseMessageProcessorsFactoryBean;
 13  
 import org.mule.config.spring.parsers.delegate.ParentContextDefinitionParser;
 14  
 import org.mule.config.spring.parsers.generic.ChildDefinitionParser;
 15  
 import org.mule.processor.chain.DefaultMessageProcessorChainBuilder;
 16  
 
 17  
 public class ResponseDefinitionParser extends ParentContextDefinitionParser
 18  
 {
 19  
 
 20  
     public ResponseDefinitionParser()
 21  
     {
 22  0
         super("endpoint", new ChildDefinitionParser("responseMessageProcessor",
 23  
             EndpointResponseMessageProcessorChainFactoryBean.class));
 24  0
         and("inbound-endpoint", new ChildDefinitionParser("responseMessageProcessor",
 25  
             EndpointResponseMessageProcessorChainFactoryBean.class));
 26  0
         and("outbound-endpoint", new ChildDefinitionParser("responseMessageProcessor",
 27  
             EndpointResponseMessageProcessorChainFactoryBean.class));
 28  0
         otherwise(new ChildDefinitionParser("messageProcessor", ResponseMessageProcessorsFactoryBean.class));
 29  0
     }
 30  
 
 31  
     // This is used to avoid additional wrapping of endpoint response message processor which shouldn't even be wrapped to start with
 32  
     // The optimal solution is to have response message processors contained inside the <response> element injected into their grandparent element directly.
 33  0
     private static class EndpointResponseMessageProcessorChainFactoryBean extends MessageProcessorChainFactoryBean
 34  
     {
 35  
         public Object getObject() throws Exception
 36  
         {
 37  0
             DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
 38  0
             builder.setName("processor chain '" + name + "'");
 39  0
             for (Object processor : processors)
 40  
             {
 41  0
                 if (processor instanceof MessageProcessor)
 42  
                 {
 43  0
                     builder.chain((MessageProcessor) processor);
 44  
                 }
 45  0
                 else if (processor instanceof MessageProcessorBuilder)
 46  
                 {
 47  0
                     builder.chain((MessageProcessorBuilder) processor);
 48  
                 }
 49  
                 else
 50  
                 {
 51  0
                     throw new IllegalArgumentException(
 52  
                         "MessageProcessorBuilder should only have MessageProcessor's or MessageProcessorBuilder's configured");
 53  
                 }
 54  
             }
 55  0
             return builder.build();
 56  
         }
 57  
     }
 58  
 
 59  
 }