Coverage Report - org.mule.config.spring.parsers.delegate.AbstractSingleParentFamilyDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractSingleParentFamilyDefinitionParser
0%
0/15
0%
0/6
2
 
 1  
 /*
 2  
  * $Id: AbstractSingleParentFamilyDefinitionParser.java 10256 2008-01-08 15:20:25Z dfeist $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.delegate;
 12  
 
 13  
 import org.mule.config.spring.parsers.MuleChildDefinitionParser;
 14  
 import org.mule.config.spring.parsers.MuleDefinitionParser;
 15  
 import org.mule.config.spring.parsers.MuleDefinitionParserConfiguration;
 16  
 
 17  
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 18  
 import org.springframework.beans.factory.xml.ParserContext;
 19  
 import org.w3c.dom.Element;
 20  
 
 21  
 /**
 22  
  * This allows several parsers to be used on a single element, creating a parent bean with
 23  
  * the first parser and then extending that with child parsers.
 24  
  *
 25  
  * <p>Note that this make a lot of assumptions about what type of parser is used.
 26  
  */
 27  
 public abstract class AbstractSingleParentFamilyDefinitionParser
 28  
         extends AbstractFirstResultSerialDefinitionParser
 29  
 {
 30  
 
 31  
     public AbstractSingleParentFamilyDefinitionParser()
 32  
     {
 33  0
         super();
 34  0
     }
 35  
 
 36  
     public AbstractSingleParentFamilyDefinitionParser(boolean doReset)
 37  
     {
 38  0
         super(doReset);
 39  0
     }
 40  
 
 41  
     protected MuleChildDefinitionParser addChildDelegate(MuleChildDefinitionParser delegate)
 42  
     {
 43  0
         return (MuleChildDefinitionParser) super.addDelegate(delegate);
 44  
     }
 45  
 
 46  
     protected MuleDefinitionParserConfiguration addDelegate(MuleDefinitionParser delegate)
 47  
     {
 48  0
         if (size() > 0)
 49  
         {
 50  0
             return addDelegateAsChild(delegate);
 51  
         }
 52  
         else
 53  
         {
 54  0
             return super.addDelegate(delegate);
 55  
         }
 56  
     }
 57  
 
 58  
     protected MuleDefinitionParserConfiguration addDelegateAsChild(MuleDefinitionParser delegate)
 59  
     {
 60  0
         if (delegate instanceof MuleChildDefinitionParser)
 61  
         {
 62  0
             return addChildDelegate((MuleChildDefinitionParser) delegate);
 63  
         }
 64  
         else
 65  
         {
 66  0
             throw new IllegalStateException("Children must implement child interface");
 67  
         }
 68  
     }
 69  
 
 70  
     protected AbstractBeanDefinition doSingleBean(int index, MuleDefinitionParser parser,
 71  
                                                   Element element, ParserContext parserContext)
 72  
     {
 73  0
         if (0 != index)
 74  
         {
 75  0
             ((MuleChildDefinitionParser) parser).forceParent(firstDefinition);
 76  
             // we need this because we often block "everything but" which would mean
 77  
             // being unable to set ourselves on the parent
 78  0
             ((MuleChildDefinitionParser) parser).getTargetPropertyConfiguration().setIgnoredDefault(false);
 79  
         }
 80  0
         return super.doSingleBean(index, parser, element, parserContext);
 81  
     }
 82  
 
 83  
 }