Coverage Report - org.mule.config.spring.parsers.specific.InvokerMessageProcessorDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
InvokerMessageProcessorDefinitionParser
0%
0/20
0%
0/8
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.config.spring.parsers.assembly.BeanAssembler;
 10  
 import org.mule.config.spring.parsers.generic.ChildDefinitionParser;
 11  
 import org.mule.processor.InvokerMessageProcessor;
 12  
 import org.mule.util.StringUtils;
 13  
 
 14  
 import java.util.ArrayList;
 15  
 import java.util.List;
 16  
 
 17  
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 18  
 import org.springframework.beans.factory.xml.ParserContext;
 19  
 import org.w3c.dom.Element;
 20  
 
 21  
 public class InvokerMessageProcessorDefinitionParser extends ChildDefinitionParser
 22  
 {
 23  
     private final Class<?> objectType;
 24  
     private final String methodName;
 25  
     private final String[] parameterNames;
 26  
 
 27  
     public InvokerMessageProcessorDefinitionParser(String setterMethod,
 28  
                                          Class<?> objectType,
 29  
                                          String methodName,
 30  
                                          String[] parameterNames)
 31  
     {
 32  0
         super(setterMethod, InvokerMessageProcessor.class);
 33  0
         this.objectType = objectType;
 34  0
         this.methodName = methodName;
 35  0
         this.parameterNames = parameterNames;
 36  0
     }
 37  
 
 38  
     @Override
 39  
     protected Class<?> getBeanClass(Element element)
 40  
     {
 41  0
         return InvokerMessageProcessor.class;
 42  
     }
 43  
 
 44  
     @Override
 45  
     protected void parseChild(Element element, ParserContext parserContext, BeanDefinitionBuilder builder)
 46  
     {
 47  0
         if (!StringUtils.isEmpty(element.getAttribute(getTargetPropertyConfiguration().getAttributeAlias(
 48  
             "config-ref"))))
 49  
         {
 50  0
             builder.addPropertyReference("object",
 51  
                 element.getAttribute(getTargetPropertyConfiguration().getAttributeAlias("config-ref")));
 52  
         }
 53  
         else
 54  
         {
 55  0
             builder.addPropertyValue("objectType", objectType);
 56  
         }
 57  
 
 58  0
         List<String> expressions = new ArrayList<String>();
 59  0
         if (parameterNames != null)
 60  
         {
 61  0
             for (String parameterName : parameterNames)
 62  
             {
 63  0
                 if (!StringUtils.isEmpty(element.getAttribute(parameterName)))
 64  
                 {
 65  0
                     expressions.add(element.getAttribute(parameterName));
 66  
                 }
 67  
                 else
 68  
                 {
 69  0
                     expressions.add(null);
 70  
                 }
 71  
             }
 72  
         }
 73  0
         builder.addPropertyValue("arguments", expressions);
 74  0
         builder.addPropertyValue("methodName", methodName);
 75  
 
 76  0
         BeanAssembler assembler = getBeanAssembler(element, builder);
 77  0
         postProcess(getParserContext(), assembler, element);
 78  0
     }
 79  
 
 80  
 }