Coverage Report - org.mule.config.spring.parsers.delegate.AbstractDelegatingDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractDelegatingDefinitionParser
0%
0/52
0%
0/26
1.65
 
 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.delegate;
 8  
 
 9  
 import org.mule.config.spring.MuleHierarchicalBeanDefinitionParserDelegate;
 10  
 import org.mule.config.spring.parsers.MuleDefinitionParser;
 11  
 import org.mule.config.spring.parsers.MuleDefinitionParserConfiguration;
 12  
 import org.mule.config.spring.parsers.PostProcessor;
 13  
 import org.mule.config.spring.parsers.PreProcessor;
 14  
 import org.mule.config.spring.parsers.assembly.configuration.ValueMap;
 15  
 import org.mule.config.spring.parsers.generic.AutoIdUtils;
 16  
 import org.mule.util.ArrayUtils;
 17  
 
 18  
 import java.util.Map;
 19  
 
 20  
 import org.apache.commons.logging.Log;
 21  
 import org.apache.commons.logging.LogFactory;
 22  
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 23  
 import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
 24  
 import org.springframework.beans.factory.xml.ParserContext;
 25  
 import org.w3c.dom.Element;
 26  
 
 27  
 /**
 28  
  * This allows a definition parsers to be dynamically represented by different
 29  
  * definition parsers, depending on the context.  For example, a single model may
 30  
  * be defined across file - the first use defines the model and subsequent uses
 31  
  * extend it (for this particular case, see {@link InheritDefinitionParser}).
 32  
  *
 33  
  * <p>Note that the sub-parsers must be consistent.  That includes matching the
 34  
  * same schema, for example.</p>
 35  
  */
 36  
 public abstract class AbstractDelegatingDefinitionParser extends AbstractBeanDefinitionParser
 37  
     implements MuleDefinitionParser
 38  
 {
 39  
 
 40  0
     protected Log logger = LogFactory.getLog(getClass());
 41  
     
 42  
     private MuleDefinitionParser[] delegates;
 43  
 
 44  
     protected AbstractDelegatingDefinitionParser()
 45  
     {
 46  0
         this(new MuleDefinitionParser[0]);
 47  0
     }
 48  
 
 49  
     protected AbstractDelegatingDefinitionParser(MuleDefinitionParser[] delegates)
 50  0
     {
 51  0
         this.delegates = delegates;
 52  0
         addBeanFlag(MuleHierarchicalBeanDefinitionParserDelegate.MULE_FORCE_RECURSE);
 53  0
     }
 54  
 
 55  
     protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext)
 56  
     {
 57  0
         return muleParse(element, parserContext);
 58  
     }
 59  
 
 60  
     protected MuleDefinitionParserConfiguration addDelegate(MuleDefinitionParser delegate)
 61  
     {
 62  0
         delegates = (MuleDefinitionParser[]) ArrayUtils.add(delegates, delegate);
 63  0
         return delegate;
 64  
     }
 65  
 
 66  
     protected int size()
 67  
     {
 68  0
         return delegates.length;
 69  
     }
 70  
 
 71  
     protected MuleDefinitionParser getDelegate(int index)
 72  
     {
 73  0
         return delegates[index];
 74  
     }
 75  
 
 76  
     public MuleDefinitionParserConfiguration registerPreProcessor(PreProcessor preProcessor)
 77  
     {
 78  0
         for (int i = 0; i < delegates.length; ++i)
 79  
         {
 80  0
             delegates[i].registerPreProcessor(preProcessor);
 81  
         }
 82  0
         return this;
 83  
     }
 84  
 
 85  
     public MuleDefinitionParserConfiguration registerPostProcessor(PostProcessor postProcessor)
 86  
     {
 87  0
         for (int i = 0; i < delegates.length; ++i)
 88  
         {
 89  0
             delegates[i].registerPostProcessor(postProcessor);
 90  
         }
 91  0
         return this;
 92  
     }
 93  
 
 94  
     public MuleDefinitionParserConfiguration addReference(String propertyName)
 95  
     {
 96  0
         for (int i = 0; i < delegates.length; ++i)
 97  
         {
 98  0
             delegates[i].addReference(propertyName);
 99  
         }
 100  0
         return this;
 101  
     }
 102  
 
 103  
     public MuleDefinitionParserConfiguration addMapping(String propertyName, Map mappings)
 104  
     {
 105  0
         for (int i = 0; i < delegates.length; ++i)
 106  
         {
 107  0
             delegates[i].addMapping(propertyName, mappings);
 108  
         }
 109  0
         return this;
 110  
     }
 111  
 
 112  
     public MuleDefinitionParserConfiguration addMapping(String propertyName, String mappings)
 113  
     {
 114  0
         for (int i = 0; i < delegates.length; ++i)
 115  
         {
 116  0
             delegates[i].addMapping(propertyName, mappings);
 117  
         }
 118  0
         return this;
 119  
     }
 120  
 
 121  
     public MuleDefinitionParserConfiguration addMapping(String propertyName, ValueMap mappings)
 122  
     {
 123  0
         for (int i = 0; i < delegates.length; ++i)
 124  
         {
 125  0
             delegates[i].addMapping(propertyName, mappings);
 126  
         }
 127  0
         return this;
 128  
     }
 129  
 
 130  
     public MuleDefinitionParserConfiguration addAlias(String alias, String propertyName)
 131  
     {
 132  0
         for (int i = 0; i < delegates.length; ++i)
 133  
         {
 134  0
             delegates[i].addAlias(alias, propertyName);
 135  
         }
 136  0
         return this;
 137  
     }
 138  
 
 139  
     public MuleDefinitionParserConfiguration addCollection(String propertyName)
 140  
     {
 141  0
         for (int i = 0; i < delegates.length; ++i)
 142  
         {
 143  0
             delegates[i].addCollection(propertyName);
 144  
         }
 145  0
         return this;
 146  
     }
 147  
 
 148  
     public MuleDefinitionParserConfiguration addIgnored(String propertyName)
 149  
     {
 150  0
         for (int i = 0; i < delegates.length; ++i)
 151  
         {
 152  0
             delegates[i].addIgnored(propertyName);
 153  
         }
 154  0
         return this;
 155  
     }
 156  
 
 157  
     public MuleDefinitionParserConfiguration removeIgnored(String propertyName)
 158  
     {
 159  0
         for (int i = 0; i < delegates.length; ++i)
 160  
         {
 161  0
             delegates[i].removeIgnored(propertyName);
 162  
         }
 163  0
         return this;
 164  
     }
 165  
 
 166  
     public MuleDefinitionParserConfiguration setIgnoredDefault(boolean ignoreAll)
 167  
     {
 168  0
         for (int i = 0; i < delegates.length; ++i)
 169  
         {
 170  0
             delegates[i].setIgnoredDefault(ignoreAll);
 171  
         }
 172  0
         return this;
 173  
     }
 174  
 
 175  
     public String getBeanName(Element element)
 176  
     {
 177  0
         return AutoIdUtils.getUniqueName(element, "delegate");
 178  
     }
 179  
 
 180  
     public MuleDefinitionParserConfiguration addBeanFlag(String flag)
 181  
     {
 182  0
         for (int i = 0; i < delegates.length; ++i)
 183  
         {
 184  0
             delegates[i].addBeanFlag(flag);
 185  
         }
 186  0
         return this;
 187  
     }
 188  
 
 189  
     public void setDeprecationWarning(String deprecationWarning)
 190  
     {
 191  0
         for (int i = 0; i < delegates.length; ++i)
 192  
         {
 193  0
             delegates[i].setDeprecationWarning(deprecationWarning);
 194  
         }
 195  0
     }
 196  
 }