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