Coverage Report - org.mule.config.spring.parsers.specific.GlobalPropertyDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
GlobalPropertyDefinitionParser
0%
0/14
0%
0/2
1.333
 
 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.MuleOrphanDefinitionParser;
 11  
 
 12  
 import org.springframework.beans.factory.xml.ParserContext;
 13  
 import org.springframework.util.SystemPropertyUtils;
 14  
 import org.w3c.dom.Element;
 15  
 
 16  
 public class GlobalPropertyDefinitionParser extends MuleOrphanDefinitionParser
 17  
 {
 18  0
     private final String VALUE_ATTR = "value";
 19  0
     private final String NAME_ATTR = "name";
 20  
 
 21  
     public GlobalPropertyDefinitionParser()
 22  
     {
 23  0
         super(true);
 24  0
         addIgnored(NAME_ATTR);
 25  0
         addIgnored(VALUE_ATTR);
 26  0
     }
 27  
 
 28  
     protected Class getBeanClass(Element element)
 29  
     {
 30  0
         return String.class;
 31  
     }
 32  
 
 33  
     protected void postProcess(ParserContext context, BeanAssembler assembler, Element element)
 34  
     {
 35  0
         String name = element.getAttribute(NAME_ATTR);
 36  0
         if(name.indexOf(' ') != -1)
 37  
         {
 38  0
             logger.warn("Environment property name should not contain spaces: \"" + name + "\"");
 39  
         }
 40  
 
 41  0
         String value = element.getAttribute(VALUE_ATTR);
 42  0
         assembler.getBean().addConstructorArgValue(SystemPropertyUtils.resolvePlaceholders(value));
 43  0
         super.postProcess(context, assembler, element);
 44  0
     }
 45  
 }