Example usage for org.springframework.beans MutablePropertyValues contains

List of usage examples for org.springframework.beans MutablePropertyValues contains

Introduction

In this page you can find the example usage for org.springframework.beans MutablePropertyValues contains.

Prototype

@Override
    public boolean contains(String propertyName) 

Source Link

Usage

From source file:org.kuali.rice.krad.datadictionary.MessageBeanProcessor.java

/**
 * Retrieves the namespace associated with the bean definition
 *
 * @param beanName name of the bean to find namespace for
 * @param beanDefinition bean definition to find namespace for
 * @return String namespace for bean or null if a namespace was not found
 *//*from   w w w.  j a v a2s .  c om*/
protected String getNamespaceForBean(String beanName, BeanDefinition beanDefinition) {
    String namespace = null;

    MutablePropertyValues pvs = beanDefinition.getPropertyValues();
    if (pvs.contains(KRADPropertyConstants.NAMESPACE_CODE)) {
        PropertyValue propertyValue = pvs.getPropertyValue(KRADPropertyConstants.NAMESPACE_CODE);
        namespace = getStringValue(propertyValue.getValue());
    } else if (StringUtils.isNotBlank(beanName) && !isGeneratedBeanName(beanName)) {
        // if not on bean definition, get from associated module in the dictionary
        namespace = dataDictionary.getNamespaceForBeanDefinition(beanName);
    }

    return namespace;
}

From source file:org.kuali.rice.krad.datadictionary.MessageBeanProcessor.java

/**
 * Retrieves the component code associated with the bean definition
 *
 * @param beanName name of the bean to find component code for
 * @param beanDefinition bean definition to find component code for
 * @return String component code for bean or null if a component code was not found
 *///from ww w  . j  a v a 2  s.  com
protected String getComponentForBean(String beanName, BeanDefinition beanDefinition) {
    String componentCode = null;

    MutablePropertyValues pvs = beanDefinition.getPropertyValues();
    if (pvs.contains(KRADPropertyConstants.COMPONENT_CODE)) {
        PropertyValue propertyValue = pvs.getPropertyValue(KRADPropertyConstants.COMPONENT_CODE);

        componentCode = getStringValue(propertyValue.getValue());
    }

    if ((componentCode == null) && StringUtils.isNotBlank(beanName) && !isGeneratedBeanName(beanName)) {
        componentCode = beanName;
    }

    if (StringUtils.isNotBlank(componentCode)) {
        componentCode = StringUtils.removeEnd(componentCode, KRADConstants.DICTIONARY_BEAN_PARENT_SUFFIX);
    }

    return componentCode;
}

From source file:org.kuali.rice.krad.datadictionary.uif.UifBeanFactoryPostProcessor.java

/**
 * Processes a top level (non nested) bean definition for expressions
 *
 * <p>/*from ww  w .  j av a 2  s  . c om*/
 * A bean that is non nested (or top of a collection) will hold all the expressions for the graph. A new
 * expression graph is initialized and expressions are collected as the bean and all its children are processed.
 * The expression graph is then set as a property on the top bean definition
 * </p>
 *
 * @param beanName name of the bean to process
 * @param beanDefinition bean definition to process
 * @param beanFactory factory holding all the bean definitions
 * @param processedBeanNames set of bean names that have already been processed
 */
protected void processBeanDefinition(String beanName, BeanDefinition beanDefinition,
        ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames) {
    Class<?> beanClass = getBeanClass(beanDefinition, beanFactory);
    if ((beanClass == null) || !UifDictionaryBean.class.isAssignableFrom(beanClass)
            || processedBeanNames.contains(beanName)) {
        return;
    }

    // process bean definition and all nested definitions for expressions
    ManagedMap<String, String> expressionGraph = new ManagedMap<String, String>();
    MutablePropertyValues pvs = beanDefinition.getPropertyValues();
    if (pvs.contains(UifPropertyPaths.EXPRESSION_GRAPH)) {
        expressionGraph = (ManagedMap<String, String>) pvs.getPropertyValue(UifPropertyPaths.EXPRESSION_GRAPH)
                .getValue();
        if (expressionGraph == null) {
            expressionGraph = new ManagedMap<String, String>();
        }
    }

    expressionGraph.setMergeEnabled(false);
    processNestedBeanDefinition(beanName, beanDefinition, "", expressionGraph, beanFactory, processedBeanNames);

    // add property for expression graph
    pvs = beanDefinition.getPropertyValues();
    pvs.addPropertyValue(UifPropertyPaths.EXPRESSION_GRAPH, expressionGraph);
}

From source file:org.mule.config.spring.parsers.assembly.DefaultBeanAssembler.java

protected void addPropertyWithoutReference(MutablePropertyValues properties, SingleProperty config, String name,
        Object value) {/*from   w w  w  . j  a  va 2 s  .  c o  m*/
    if (!config.isIgnored()) {
        if (logger.isDebugEnabled()) {
            logger.debug(name + ": " + value);
        }
        Object oldValue = null;
        if (properties.contains(name)) {
            oldValue = properties.getPropertyValue(name).getValue();
        }
        // merge collections
        if (config.isCollection() || oldValue instanceof Collection || value instanceof Collection) {
            Collection values = new ManagedList();
            if (null != oldValue) {
                properties.removePropertyValue(name);
                if (oldValue instanceof Collection) {
                    values.addAll((Collection) oldValue);
                } else {
                    values.add(oldValue);
                }
            }
            if (value instanceof Collection) {
                values.addAll((Collection) value);
            } else {
                values.add(value);
            }
            properties.addPropertyValue(name, values);
        } else {
            properties.addPropertyValue(name, value);
        }
    }
}

From source file:org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader.java

/**
 * This method overrides property retrieval in the scope of the
 * {@code GroovyBeanDefinitionReader} to either:
 * <ul>//from  ww w  . ja v  a 2  s.c om
 * <li>Retrieve a variable from the bean builder's binding if it exists
 * <li>Retrieve a RuntimeBeanReference for a specific bean if it exists
 * <li>Otherwise just delegate to MetaClass.getProperty which will resolve
 * properties from the {@code GroovyBeanDefinitionReader} itself
 * </ul>
 */
public Object getProperty(String name) {
    Binding binding = getBinding();
    if (binding != null && binding.hasVariable(name)) {
        return binding.getVariable(name);
    } else {
        if (this.namespaces.containsKey(name)) {
            return createDynamicElementReader(name);
        }
        if (getRegistry().containsBeanDefinition(name)) {
            GroovyBeanDefinitionWrapper beanDefinition = (GroovyBeanDefinitionWrapper) getRegistry()
                    .getBeanDefinition(name).getAttribute(GroovyBeanDefinitionWrapper.class.getName());
            if (beanDefinition != null) {
                return new GroovyRuntimeBeanReference(name, beanDefinition, false);
            } else {
                return new RuntimeBeanReference(name, false);
            }
        }
        // This is to deal with the case where the property setter is the last
        // statement in a closure (hence the return value)
        else if (this.currentBeanDefinition != null) {
            MutablePropertyValues pvs = this.currentBeanDefinition.getBeanDefinition().getPropertyValues();
            if (pvs.contains(name)) {
                return pvs.get(name);
            } else {
                DeferredProperty dp = this.deferredProperties
                        .get(this.currentBeanDefinition.getBeanName() + name);
                if (dp != null) {
                    return dp.value;
                } else {
                    return getMetaClass().getProperty(this, name);
                }
            }
        } else {
            return getMetaClass().getProperty(this, name);
        }
    }
}

From source file:org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.java

/**
 * Parse a property element./*from  w  ww. j a  v a 2 s. c o  m*/
 */
protected void parsePropertyElement(Element ele, String beanName, MutablePropertyValues pvs)
        throws BeanDefinitionStoreException {

    String propertyName = ele.getAttribute(NAME_ATTRIBUTE);
    if (!StringUtils.hasLength(propertyName)) {
        throw new BeanDefinitionStoreException(getResource(), beanName,
                "Tag 'property' must have a 'name' attribute");
    }
    if (pvs.contains(propertyName)) {
        throw new BeanDefinitionStoreException(getResource(), beanName,
                "Multiple 'property' definitions for property '" + propertyName + "'");
    }
    Object val = parsePropertyValue(ele, beanName, propertyName);
    pvs.addPropertyValue(propertyName, val);
}