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