Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/
package org.mule.config.spring.parsers.assembly;
import org.mule.api.AnnotatedObject;
import org.mule.api.MuleContext;
import org.mule.config.spring.MuleArtifactContext;
import org.mule.config.spring.MuleHierarchicalBeanDefinitionParserDelegate;
import org.mule.config.spring.parsers.assembly.configuration.PropertyConfiguration;
import org.mule.config.spring.parsers.assembly.configuration.SingleProperty;
import org.mule.config.spring.parsers.assembly.configuration.SinglePropertyLiteral;
import org.mule.config.spring.parsers.assembly.configuration.SinglePropertyWrapper;
import org.mule.config.spring.parsers.collection.ChildListEntryDefinitionParser;
import org.mule.config.spring.parsers.collection.ChildMapEntryDefinitionParser;
import org.mule.config.spring.util.SpringXMLUtils;
import org.mule.util.ClassUtils;
import org.mule.util.MapCombiner;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import javax.xml.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.MapFactoryBean;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.support.ManagedMap;
import org.w3c.dom.Attr;
public class DefaultBeanAssembler implements BeanAssembler
{
private static Log logger = LogFactory.getLog(DefaultBeanAssembler.class);
private PropertyConfiguration beanConfig;
protected BeanDefinitionBuilder bean;
protected PropertyConfiguration targetConfig;
protected BeanDefinition target;
public DefaultBeanAssembler(PropertyConfiguration beanConfig, BeanDefinitionBuilder bean,
PropertyConfiguration targetConfig, BeanDefinition target)
{
this.beanConfig = beanConfig;
this.bean = bean;
this.targetConfig = targetConfig;
this.target = target;
}
public BeanDefinitionBuilder getBean()
{
return bean;
}
protected void setBean(BeanDefinitionBuilder bean)
{
this.bean = bean;
}
public BeanDefinition getTarget()
{
return target;
}
protected PropertyConfiguration getBeanConfig()
{
return beanConfig;
}
protected PropertyConfiguration getTargetConfig()
{
return targetConfig;
}
/**
* 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 {@link org.mule.config.spring.parsers.assembly.configuration.PropertyConfiguration})
* @param attribute The attribute to add
*/
public void extendBean(Attr attribute)
{
AbstractBeanDefinition beanDefinition = bean.getBeanDefinition();
String oldName = SpringXMLUtils.attributeName(attribute);
String oldValue = attribute.getNodeValue();
if (attribute.getNamespaceURI() == null)
{
if (!beanConfig.isIgnored(oldName))
{
logger.debug(attribute + " for " + beanDefinition.getBeanClassName());
String newName = bestGuessName(beanConfig, oldName, beanDefinition.getBeanClassName());
Object newValue = beanConfig.translateValue(oldName, oldValue);
addPropertyWithReference(beanDefinition.getPropertyValues(),
beanConfig.getSingleProperty(oldName), newName, newValue);
}
}
else if (isAnnotationsPropertyAvailable(beanDefinition.getBeanClass()))
{
//Add attribute defining namespace as annotated elements. No reconciliation is done here ie new values override old ones.
QName name;
if (attribute.getPrefix() != null)
{
name = new QName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix());
}
else
{
name = new QName(attribute.getNamespaceURI(), attribute.getLocalName());
}
Object value = beanConfig.translateValue(oldName, oldValue);
addAnnotationValue(beanDefinition.getPropertyValues(), name, value);
MuleContext muleContext = MuleArtifactContext.getCurrentMuleContext().get();
if (muleContext != null)
{
Map> annotations = muleContext.getConfigurationAnnotations();
Set