Coverage Report - org.mule.config.spring.parsers.generic.OrphanDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
OrphanDefinitionParser
0%
0/16
0%
0/2
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.generic;
 8  
 
 9  
 import org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser;
 10  
 
 11  
 import org.w3c.dom.Element;
 12  
 
 13  
 /**
 14  
  * <p>
 15  
  * Contructs a single, standalone bean from an element - it is not injected into any
 16  
  * other object. This parser can be configured to automatically set the class of the
 17  
  * object, the init and destroy methods and whether this object is a singleton.
 18  
  * </p>
 19  
  * <p>
 20  
  * Typically, you should use {@link MuleOrphanDefinitionParser} instead of this
 21  
  * class, since these elements occur in the <mule> top level element.
 22  
  * </p>
 23  
  */
 24  
 public class OrphanDefinitionParser extends AbstractMuleBeanDefinitionParser
 25  
 {
 26  0
     private Class<?> beanClass = null;
 27  0
     private boolean dynamicClass = false;
 28  
 
 29  
     /**
 30  
      * This constructor assumes that the class name will be explicitly specified as
 31  
      * an attribute on the element.
 32  
      */
 33  
     public OrphanDefinitionParser(boolean singleton)
 34  0
     {
 35  0
         this.singleton = singleton;
 36  0
         dynamicClass = true;
 37  0
     }
 38  
 
 39  
     public OrphanDefinitionParser(Class<?> beanClass, boolean singleton)
 40  0
     {
 41  0
         this.beanClass = beanClass;
 42  0
         this.singleton = singleton;
 43  0
     }
 44  
 
 45  
     @Override
 46  
     protected void preProcess(Element element)
 47  
     {
 48  0
         super.preProcess(element);
 49  
         // top level beans need an ID element
 50  0
         AutoIdUtils.ensureUniqueId(element, "bean");
 51  0
         if (dynamicClass)
 52  
         {
 53  0
             beanClass = null;
 54  
         }
 55  0
     }
 56  
 
 57  
     @Override
 58  
     protected Class<?> getBeanClass(Element element)
 59  
     {
 60  0
         return beanClass;
 61  
     }
 62  
 }