org.mule.config.spring.parsers.assembly
Class DefaultBeanAssembler

java.lang.Object
  extended by org.mule.config.spring.parsers.assembly.DefaultBeanAssembler
All Implemented Interfaces:
BeanAssembler
Direct Known Subclasses:
AbstractMapBeanAssembler

public class DefaultBeanAssembler
extends Object
implements BeanAssembler


Field Summary
protected  org.springframework.beans.factory.support.BeanDefinitionBuilder bean
           
protected  org.springframework.beans.factory.config.BeanDefinition target
           
protected  PropertyConfiguration targetConfig
           
 
Constructor Summary
DefaultBeanAssembler(PropertyConfiguration beanConfig, org.springframework.beans.factory.support.BeanDefinitionBuilder bean, PropertyConfiguration targetConfig, org.springframework.beans.factory.config.BeanDefinition target)
           
 
Method Summary
 void addAnnotationValue(org.springframework.beans.MutablePropertyValues properties, QName name, Object value)
          Add a key/value pair to existing AnnotatedObject.PROPERTY_NAME property value.
protected  void addPropertyWithoutReference(org.springframework.beans.MutablePropertyValues properties, SingleProperty config, String name, Object value)
           
protected  void addPropertyWithReference(org.springframework.beans.MutablePropertyValues properties, SingleProperty config, String name, Object value)
           
protected  void assertTargetPresent()
           
protected static String bestGuessName(PropertyConfiguration config, String oldName, String className)
           
 void copyBeanToTarget()
          Copy the properties from the bean we have been building into the target (typically the parent bean).
 void extendBean(Attr attribute)
          Add a property defined by an attribute to the bean we are constructing.
 void extendBean(String newName, Object newValue, boolean isReference)
          Allow direct access to bean for major hacks
 void extendTarget(Attr attribute)
          Add a property defined by an attribute to the parent of the bean we are constructing.
 void extendTarget(String newName, Object newValue, boolean isReference)
          Allow direct access to target for major hacks
 void extendTarget(String oldName, String newName, Object newValue)
           
 org.springframework.beans.factory.support.BeanDefinitionBuilder getBean()
           
protected  PropertyConfiguration getBeanConfig()
           
 org.springframework.beans.factory.config.BeanDefinition getTarget()
           
protected  PropertyConfiguration getTargetConfig()
           
 void insertBeanInTarget(String oldName)
          Insert the bean we have built into the target (typically the parent bean).
protected  void insertInTarget(String oldName)
           
 void insertSingletonBeanInTarget(String propertyName, String singletonName)
           
 boolean isAnnotationsPropertyAvailable(Class<?> beanClass)
           
 boolean isAnnotationsPropertyAvailable(String beanClassName)
           
protected static boolean methodExists(String className, String newName)
           
protected static List retrieveList(Object value)
           
protected  void setBean(org.springframework.beans.factory.support.BeanDefinitionBuilder bean)
           
 void setBeanFlag(String flag)
          Set a flag on the bean - this is used to communicate with MuleHierarchicalBeanDefinitionParserDelegate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bean

protected org.springframework.beans.factory.support.BeanDefinitionBuilder bean

targetConfig

protected PropertyConfiguration targetConfig

target

protected org.springframework.beans.factory.config.BeanDefinition target
Constructor Detail

DefaultBeanAssembler

public DefaultBeanAssembler(PropertyConfiguration beanConfig,
                            org.springframework.beans.factory.support.BeanDefinitionBuilder bean,
                            PropertyConfiguration targetConfig,
                            org.springframework.beans.factory.config.BeanDefinition target)
Method Detail

getBean

public org.springframework.beans.factory.support.BeanDefinitionBuilder getBean()
Specified by:
getBean in interface BeanAssembler

setBean

protected void setBean(org.springframework.beans.factory.support.BeanDefinitionBuilder bean)

getTarget

public org.springframework.beans.factory.config.BeanDefinition getTarget()
Specified by:
getTarget in interface BeanAssembler

getBeanConfig

protected PropertyConfiguration getBeanConfig()

getTargetConfig

protected PropertyConfiguration getTargetConfig()

extendBean

public void extendBean(Attr attribute)
Add a property defined by an attribute to the bean we are constructing.

Since an attribute value is always a string, we don't have to deal with complex types here - the only issue is whether or not we have a reference. References are detected by explicit annotation or by the "-ref" at the end of an attribute name. We do not check the Spring repo to see if a name already exists since that could lead to unpredictable behaviour. (see PropertyConfiguration)

Specified by:
extendBean in interface BeanAssembler
Parameters:
attribute - The attribute to add

isAnnotationsPropertyAvailable

public final boolean isAnnotationsPropertyAvailable(Class<?> beanClass)
Returns:
true if specified class defines a setAnnotations method.

isAnnotationsPropertyAvailable

public final boolean isAnnotationsPropertyAvailable(String beanClassName)
Returns:
true if specified class defines a setAnnotations method.

extendBean

public void extendBean(String newName,
                       Object newValue,
                       boolean isReference)
Allow direct access to bean for major hacks

Specified by:
extendBean in interface BeanAssembler
Parameters:
newName - The property name to add
newValue - The property value to add
isReference - If true, a bean reference is added (and newValue must be a String)

extendTarget

public void extendTarget(Attr attribute)
Add a property defined by an attribute to the parent of the bean we are constructing.

This is unusual. Normally you want extendBean(org.w3c.dom.Attr).

Specified by:
extendTarget in interface BeanAssembler
Parameters:
attribute - The attribute to add

extendTarget

public void extendTarget(String newName,
                         Object newValue,
                         boolean isReference)
Allow direct access to target for major hacks

Specified by:
extendTarget in interface BeanAssembler
Parameters:
newName - The property name to add
newValue - The property value to add
isReference - If true, a bean reference is added (and newValue must be a String)

extendTarget

public void extendTarget(String oldName,
                         String newName,
                         Object newValue)
Specified by:
extendTarget in interface BeanAssembler

insertBeanInTarget

public void insertBeanInTarget(String oldName)
Insert the bean we have built into the target (typically the parent bean).

This is the most complex case because the bean can have an aribtrary type.

Specified by:
insertBeanInTarget in interface BeanAssembler
Parameters:
oldName - The identifying the bean (typically element name).

insertSingletonBeanInTarget

public void insertSingletonBeanInTarget(String propertyName,
                                        String singletonName)
Specified by:
insertSingletonBeanInTarget in interface BeanAssembler

insertInTarget

protected void insertInTarget(String oldName)

retrieveList

protected static List retrieveList(Object value)

copyBeanToTarget

public void copyBeanToTarget()
Copy the properties from the bean we have been building into the target (typically the parent bean). In other words, the bean is a facade for the target.

This assumes that the source bean has been constructed correctly (ie the decisions about what is ignored, a map, a list, etc) have already been made. All it does (apart from a direct copy) is merge collections with those on the target when necessary.

Specified by:
copyBeanToTarget in interface BeanAssembler

setBeanFlag

public void setBeanFlag(String flag)
Description copied from interface: BeanAssembler
Set a flag on the bean - this is used to communicate with MuleHierarchicalBeanDefinitionParserDelegate

Specified by:
setBeanFlag in interface BeanAssembler
Parameters:
flag - The flag to set

assertTargetPresent

protected void assertTargetPresent()

addAnnotationValue

public final void addAnnotationValue(org.springframework.beans.MutablePropertyValues properties,
                                     QName name,
                                     Object value)
Add a key/value pair to existing AnnotatedObject.PROPERTY_NAME property value.


addPropertyWithReference

protected void addPropertyWithReference(org.springframework.beans.MutablePropertyValues properties,
                                        SingleProperty config,
                                        String name,
                                        Object value)

addPropertyWithoutReference

protected void addPropertyWithoutReference(org.springframework.beans.MutablePropertyValues properties,
                                           SingleProperty config,
                                           String name,
                                           Object value)

bestGuessName

protected static String bestGuessName(PropertyConfiguration config,
                                      String oldName,
                                      String className)

methodExists

protected static boolean methodExists(String className,
                                      String newName)


Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.