Coverage Report - org.mule.config.spring.parsers.specific.AbstractFlowConstructDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractFlowConstructDefinitionParser
0%
0/19
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.config.spring.parsers.AbstractMuleBeanDefinitionParser;
 10  
 import org.mule.util.StringUtils;
 11  
 import org.springframework.beans.factory.config.BeanDefinition;
 12  
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 13  
 import org.springframework.beans.factory.xml.ParserContext;
 14  
 import org.w3c.dom.Element;
 15  
 
 16  0
 public abstract class AbstractFlowConstructDefinitionParser extends AbstractMuleBeanDefinitionParser
 17  
 {
 18  
     private static final String MODEL_ELEMENT = "model";
 19  
     private static final String ABSTRACT_ATTRIBUTE = "abstract";
 20  
     private static final String PARENT_ATTRIBUTE = "parent";
 21  
 
 22  
     protected static final String ENDPOINT_REF_ATTRIBUTE = "endpoint-ref";
 23  
     protected static final String ADDRESS_ATTRIBUTE = "address";
 24  
 
 25  
     protected static final String INBOUND_ADDRESS_ATTRIBUTE = "inboundAddress";
 26  
     protected static final String INBOUND_ENDPOINT_REF_ATTRIBUTE = "inboundEndpoint-ref";
 27  
     protected static final String INBOUND_ENDPOINT_CHILD = "inbound-endpoint";
 28  
 
 29  
     protected static final String OUTBOUND_ADDRESS_ATTRIBUTE = "outboundAddress";
 30  
     protected static final String OUTBOUND_ENDPOINT_REF_ATTRIBUTE = "outboundEndpoint-ref";
 31  
     protected static final String OUTBOUND_ENDPOINT_CHILD = "outboundEndpoint";
 32  
 
 33  
     protected static final String TRANSFORMER_REFS_ATTRIBUTE = "transformer-refs";
 34  
     protected static final String RESPONSE_TRANSFORMER_REFS_ATTRIBUTE = "responseTransformer-refs";
 35  
 
 36  
     @Override
 37  
     @SuppressWarnings("unchecked")
 38  
     protected BeanDefinitionBuilder createBeanDefinitionBuilder(Element element, Class beanClass)
 39  
     {
 40  0
         return BeanDefinitionBuilder.genericBeanDefinition(beanClass);
 41  
     }
 42  
 
 43  
     @Override
 44  
     protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder)
 45  
     {
 46  0
         if (MODEL_ELEMENT.equals(element.getParentNode().getLocalName()))
 47  
         {
 48  0
             logger.warn("Support for pattern elements in model will be removed from Mule 3.1: move the "
 49  
                         + element.getLocalName() + " named '" + element.getAttribute("name")
 50  
                         + "' out of model as soon as possible!");
 51  
         }
 52  
 
 53  0
         builder.setScope(BeanDefinition.SCOPE_SINGLETON);
 54  0
         handleAbstractAttribute(element, builder);
 55  0
         handleParentAttribute(element, builder);
 56  0
         super.doParse(element, parserContext, builder);
 57  0
     }
 58  
 
 59  
     private void handleParentAttribute(Element element, BeanDefinitionBuilder builder)
 60  
     {
 61  0
         final String parentAttribute = element.getAttribute(PARENT_ATTRIBUTE);
 62  0
         if (StringUtils.isNotBlank(parentAttribute))
 63  
         {
 64  0
             builder.setParentName(parentAttribute);
 65  
         }
 66  0
         element.removeAttribute(PARENT_ATTRIBUTE);
 67  0
     }
 68  
 
 69  
     private void handleAbstractAttribute(Element element, BeanDefinitionBuilder builder)
 70  
     {
 71  0
         final String abstractAttribute = element.getAttribute(ABSTRACT_ATTRIBUTE);
 72  0
         if (StringUtils.isNotBlank(abstractAttribute))
 73  
         {
 74  0
             builder.setAbstract(Boolean.parseBoolean(abstractAttribute));
 75  
         }
 76  0
         element.removeAttribute(ABSTRACT_ATTRIBUTE);
 77  0
     }
 78  
 }