Coverage Report - org.mule.config.spring.parsers.assembly.BeanAssembler
 
Classes in this File Line Coverage Branch Coverage Complexity
BeanAssembler
N/A
N/A
1
 
 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.assembly;
 8  
 
 9  
 import org.springframework.beans.factory.config.BeanDefinition;
 10  
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 11  
 import org.w3c.dom.Attr;
 12  
 
 13  
 /**
 14  
  * Bean Assembler provides a high-level interface to constructing beans.  It encapsulates all
 15  
  * the "smart" logic about collections, maps, references, etc.
 16  
  *
 17  
  * <p>A bean assembly contains a bean (the thing we are constructing), a target (where we put the
 18  
  * bean once it is ready) and appropriate configuration information (there is a configuration
 19  
  * for both bean and target, but currently they are set to the same instance by the classes that
 20  
  * use this).
 21  
  */
 22  
 public interface BeanAssembler
 23  
 {
 24  
 
 25  
     public BeanDefinitionBuilder getBean();
 26  
     public BeanDefinition getTarget();
 27  
 
 28  
     /**
 29  
      * Add a property defined by an attribute to the bean we are constructing.
 30  
      *
 31  
      * <p>Since an attribute value is always a string, we don't have to deal with complex types
 32  
      * here - the only issue is whether or not we have a reference.  References are detected
 33  
      * by explicit annotation or by the "-ref" at the end of an attribute name.  We do not
 34  
      * check the Spring repo to see if a name already exists since that could lead to
 35  
      * unpredictable behaviour.
 36  
      * (see {@link org.mule.config.spring.parsers.assembly.configuration.PropertyConfiguration})
 37  
      * @param attribute The attribute to add
 38  
      */
 39  
     void extendBean(Attr attribute);
 40  
 
 41  
     /**
 42  
      * Allow direct access to bean for more complex cases
 43  
      *
 44  
      * @param newName The property name to add
 45  
      * @param newValue The property value to add
 46  
      * @param isReference If true, a bean reference is added (and newValue must be a String)
 47  
      */
 48  
     void extendBean(String newName, Object newValue, boolean isReference);
 49  
 
 50  
     /**
 51  
      * Add a property defined by an attribute to the parent of the bean we are constructing.
 52  
      *
 53  
      * <p>This is unusual.  Normally you want {@link #extendBean(org.w3c.dom.Attr)}.
 54  
      * @param attribute The attribute to add
 55  
      */
 56  
     void extendTarget(Attr attribute);
 57  
 
 58  
     /**
 59  
      * Allow direct access to target for more complex cases
 60  
      *
 61  
      * @param newName The property name to add
 62  
      * @param newValue The property value to add
 63  
      * @param isReference If true, a bean reference is added (and newValue must be a String)
 64  
      */
 65  
     void extendTarget(String newName, Object newValue, boolean isReference);
 66  
 
 67  
     void extendTarget(String oldName, String newName, Object newValue);
 68  
 
 69  
     /**
 70  
      * Insert the bean we have built into the target (typically the parent bean).
 71  
      *
 72  
      * <p>This is the most complex case because the bean can have an arbitrary type.
 73  
      * @param oldName The identifying the bean (typically element name).
 74  
      */
 75  
     void insertBeanInTarget(String oldName);
 76  
 
 77  
     void insertSingletonBeanInTarget(String propertyName, String singletonName);
 78  
     
 79  
     /**
 80  
      * Copy the properties from the bean we have been building into the target (typically
 81  
      * the parent bean).  In other words, the bean is a facade for the target.
 82  
      *
 83  
      * <p>This assumes that the source bean has been constructed correctly (ie the decisions about
 84  
      * what is ignored, a map, a list, etc) have already been made.   All it does (apart from a
 85  
      * direct copy) is merge collections with those on the target when necessary.
 86  
      */
 87  
     void copyBeanToTarget();
 88  
 
 89  
     /**
 90  
      * Set a flag on the bean - this is used to communicate with
 91  
      * {@link org.mule.config.spring.MuleHierarchicalBeanDefinitionParserDelegate}
 92  
      *
 93  
      * @param flag The flag to set
 94  
      */
 95  
     void setBeanFlag(String flag);
 96  
 
 97  
 }