Example usage for org.springframework.beans.factory.config TypedStringValue TypedStringValue

List of usage examples for org.springframework.beans.factory.config TypedStringValue TypedStringValue

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config TypedStringValue TypedStringValue.

Prototype

public TypedStringValue(@Nullable String value) 

Source Link

Document

Create a new TypedStringValue for the given String value.

Usage

From source file:com.cloudy.common.spring.SpeedUpSpringProcessor.java

private boolean needRemove(String beanName, BeanDefinition beanDefinition) {

    if (ArrayUtils.isNotEmpty(removedBeanNames)) {
        for (String removedBeanName : removedBeanNames) {
            if (beanName.equals(removedBeanName)) {
                return true;
            }/*from w  w  w  .  j  ava  2  s . co m*/
            if (beanDefinition.getBeanClassName().equals(removedBeanName)) {
                return true;
            }
        }
    }

    if (this.removedBeanProperties != null) {
        Set<String[]> propertiesSet = removedBeanProperties.get(beanName);
        if (propertiesSet != null) {
            Iterator<String[]> iter = propertiesSet.iterator();
            MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();

            while (iter.hasNext()) {
                String[] properties = iter.next();
                if (properties.length == 1) {

                    //
                    propertyValues.removePropertyValue(properties[0]);

                    //?????
                    if (this.replaceBeanProperties != null) {
                        String key = beanName + "@" + properties[0];
                        if (this.replaceBeanProperties.containsKey(key)) {
                            propertyValues.add(properties[0], this.replaceBeanProperties.get(key));
                        }
                    }
                } else {
                    PropertyValue propertyValue = propertyValues.getPropertyValue(properties[0]);
                    if (propertyValue != null) {
                        Object nextValue = propertyValue.getValue();
                        //???  + Map
                        if (nextValue instanceof ManagedMap) {

                            TypedStringValue typedStringValue = new TypedStringValue(properties[1]);
                            ((ManagedMap) nextValue).remove(typedStringValue);

                            //?????
                            if (this.replaceBeanProperties != null) {
                                String key = beanName + "@" + properties[0] + "@" + properties[1];
                                if (this.replaceBeanProperties.containsKey(key)) {
                                    ((ManagedMap) nextValue).put(properties[1],
                                            this.replaceBeanProperties.get(key));
                                }
                            }
                        }
                    }
                }
            }

        }
    }

    String className = beanDefinition.getBeanClassName();

    //spring data jpa
    if (className.equals("com.ibm.common.repository.support.SimpleBaseRepositoryFactoryBean")
            || className.equals("org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean")) {
        PropertyValue repositoryInterfaceValue = beanDefinition.getPropertyValues()
                .getPropertyValue("repositoryInterface");
        if (repositoryInterfaceValue != null) {
            className = repositoryInterfaceValue.getValue().toString();
        }
    }

    if (ArrayUtils.isEmpty(this.removedClassPatterns)) {
        return false;
    }

    if (ArrayUtils.isNotEmpty(this.includeClassPatterns)) {
        for (String includeClassPattern : includeClassPatterns) {
            if (className.matches(includeClassPattern)) {
                return false;
            }
        }
    }

    for (String removedClassPattern : removedClassPatterns) {
        if (className.matches(removedClassPattern)) {
            return true;
        }
    }

    return false;
}

From source file:com.cykj.base.common.spring.SpeedUpSpringProcessor.java

private boolean needRemove(String beanName, BeanDefinition beanDefinition) {

    if (ArrayUtils.isNotEmpty(removedBeanNames)) {
        for (String removedBeanName : removedBeanNames) {
            if (beanName.equals(removedBeanName)) {
                return true;
            }//from w  ww.  java  2 s.co m
            if (beanDefinition.getBeanClassName().equals(removedBeanName)) {
                return true;
            }
        }
    }

    if (this.removedBeanProperties != null) {
        Set<String[]> propertiesSet = removedBeanProperties.get(beanName);
        if (propertiesSet != null) {
            Iterator<String[]> iter = propertiesSet.iterator();
            MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();

            while (iter.hasNext()) {
                String[] properties = iter.next();
                if (properties.length == 1) {

                    //
                    propertyValues.removePropertyValue(properties[0]);

                    //?????
                    if (this.replaceBeanProperties != null) {
                        String key = beanName + "@" + properties[0];
                        if (this.replaceBeanProperties.containsKey(key)) {
                            propertyValues.add(properties[0], this.replaceBeanProperties.get(key));
                        }
                    }
                } else {
                    PropertyValue propertyValue = propertyValues.getPropertyValue(properties[0]);
                    if (propertyValue != null) {
                        Object nextValue = propertyValue.getValue();
                        //???  + Map
                        if (nextValue instanceof ManagedMap) {

                            TypedStringValue typedStringValue = new TypedStringValue(properties[1]);
                            ((ManagedMap) nextValue).remove(typedStringValue);

                            //?????
                            if (this.replaceBeanProperties != null) {
                                String key = beanName + "@" + properties[0] + "@" + properties[1];
                                if (this.replaceBeanProperties.containsKey(key)) {
                                    ((ManagedMap) nextValue).put(properties[1],
                                            this.replaceBeanProperties.get(key));
                                }
                            }
                        }
                    }
                }
            }

        }
    }

    String className = beanDefinition.getBeanClassName();

    //spring data jpa
    if (className.equals("com.sishuok.es.common.repository.support.SimpleBaseRepositoryFactoryBean")
            || className.equals("org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean")) {
        PropertyValue repositoryInterfaceValue = beanDefinition.getPropertyValues()
                .getPropertyValue("repositoryInterface");
        if (repositoryInterfaceValue != null) {
            className = repositoryInterfaceValue.getValue().toString();
        }
    }

    if (ArrayUtils.isEmpty(this.removedClassPatterns)) {
        return false;
    }

    if (ArrayUtils.isNotEmpty(this.includeClassPatterns)) {
        for (String includeClassPattern : includeClassPatterns) {
            if (className.matches(includeClassPattern)) {
                return false;
            }
        }
    }

    for (String removedClassPattern : removedClassPatterns) {
        if (className.matches(removedClassPattern)) {
            return true;
        }
    }

    return false;
}

From source file:com.daphne.es.common.spring.SpeedUpSpringProcessor.java

private boolean needRemove(String beanName, BeanDefinition beanDefinition) {

    if (ArrayUtils.isNotEmpty(removedBeanNames)) {
        for (String removedBeanName : removedBeanNames) {
            if (beanName.equals(removedBeanName)) {
                return true;
            }/*from  www .j a va  2 s .  c  o  m*/
            if (beanDefinition.getBeanClassName().equals(removedBeanName)) {
                return true;
            }
        }
    }

    if (this.removedBeanProperties != null) {
        Set<String[]> propertiesSet = removedBeanProperties.get(beanName);
        if (propertiesSet != null) {
            Iterator<String[]> iter = propertiesSet.iterator();
            MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();

            while (iter.hasNext()) {
                String[] properties = iter.next();
                if (properties.length == 1) {

                    //
                    propertyValues.removePropertyValue(properties[0]);

                    //?????
                    if (this.replaceBeanProperties != null) {
                        String key = beanName + "@" + properties[0];
                        if (this.replaceBeanProperties.containsKey(key)) {
                            propertyValues.add(properties[0], this.replaceBeanProperties.get(key));
                        }
                    }
                } else {
                    PropertyValue propertyValue = propertyValues.getPropertyValue(properties[0]);
                    if (propertyValue != null) {
                        Object nextValue = propertyValue.getValue();
                        //???  + Map
                        if (nextValue instanceof ManagedMap) {

                            TypedStringValue typedStringValue = new TypedStringValue(properties[1]);
                            ((ManagedMap) nextValue).remove(typedStringValue);

                            //?????
                            if (this.replaceBeanProperties != null) {
                                String key = beanName + "@" + properties[0] + "@" + properties[1];
                                if (this.replaceBeanProperties.containsKey(key)) {
                                    ((ManagedMap) nextValue).put(properties[1],
                                            this.replaceBeanProperties.get(key));
                                }
                            }
                        }
                    }
                }
            }

        }
    }

    String className = beanDefinition.getBeanClassName();

    //spring data jpa
    if (className.equals("com.daphne.es.common.repository.support.SimpleBaseRepositoryFactoryBean")
            || className.equals("org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean")) {
        PropertyValue repositoryInterfaceValue = beanDefinition.getPropertyValues()
                .getPropertyValue("repositoryInterface");
        if (repositoryInterfaceValue != null) {
            className = repositoryInterfaceValue.getValue().toString();
        }
    }

    if (ArrayUtils.isEmpty(this.removedClassPatterns)) {
        return false;
    }

    if (ArrayUtils.isNotEmpty(this.includeClassPatterns)) {
        for (String includeClassPattern : includeClassPatterns) {
            if (className.matches(includeClassPattern)) {
                return false;
            }
        }
    }

    for (String removedClassPattern : removedClassPatterns) {
        if (className.matches(removedClassPattern)) {
            return true;
        }
    }

    return false;
}

From source file:com.thinker.arch.common.spring.SpeedUpSpringProcessor.java

private boolean needRemove(String beanName, BeanDefinition beanDefinition) {

    if (ArrayUtils.isNotEmpty(removedBeanNames)) {
        for (String removedBeanName : removedBeanNames) {
            if (beanName.equals(removedBeanName)) {
                return true;
            }/*w w  w .j  ava2 s  .  c  o  m*/
            if (beanDefinition.getBeanClassName().equals(removedBeanName)) {
                return true;
            }
        }
    }

    if (this.removedBeanProperties != null) {
        Set<String[]> propertiesSet = removedBeanProperties.get(beanName);
        if (propertiesSet != null) {
            Iterator<String[]> iter = propertiesSet.iterator();
            MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();

            while (iter.hasNext()) {
                String[] properties = iter.next();
                if (properties.length == 1) {

                    //
                    propertyValues.removePropertyValue(properties[0]);

                    //?????
                    if (this.replaceBeanProperties != null) {
                        String key = beanName + "@" + properties[0];
                        if (this.replaceBeanProperties.containsKey(key)) {
                            propertyValues.add(properties[0], this.replaceBeanProperties.get(key));
                        }
                    }
                } else {
                    PropertyValue propertyValue = propertyValues.getPropertyValue(properties[0]);
                    if (propertyValue != null) {
                        Object nextValue = propertyValue.getValue();
                        //???  + Map
                        if (nextValue instanceof ManagedMap) {

                            TypedStringValue typedStringValue = new TypedStringValue(properties[1]);
                            ((ManagedMap) nextValue).remove(typedStringValue);

                            //?????
                            if (this.replaceBeanProperties != null) {
                                String key = beanName + "@" + properties[0] + "@" + properties[1];
                                if (this.replaceBeanProperties.containsKey(key)) {
                                    ((ManagedMap) nextValue).put(properties[1],
                                            this.replaceBeanProperties.get(key));
                                }
                            }
                        }
                    }
                }
            }

        }
    }

    String className = beanDefinition.getBeanClassName();

    //spring data jpa
    if (className.equals("com.thinker.arch.common.repository.support.SimpleBaseRepositoryFactoryBean")
            || className.equals("org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean")) {
        PropertyValue repositoryInterfaceValue = beanDefinition.getPropertyValues()
                .getPropertyValue("repositoryInterface");
        if (repositoryInterfaceValue != null) {
            className = repositoryInterfaceValue.getValue().toString();
        }
    }

    if (ArrayUtils.isEmpty(this.removedClassPatterns)) {
        return false;
    }

    if (ArrayUtils.isNotEmpty(this.includeClassPatterns)) {
        for (String includeClassPattern : includeClassPatterns) {
            if (className.matches(includeClassPattern)) {
                return false;
            }
        }
    }

    for (String removedClassPattern : removedClassPatterns) {
        if (className.matches(removedClassPattern)) {
            return true;
        }
    }

    return false;
}

From source file:com.weibo.api.motan.config.springsupport.MotanBeanDefinitionParser.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private static BeanDefinition parse(Element element, ParserContext parserContext, Class<?> beanClass,
        boolean required) throws ClassNotFoundException {
    RootBeanDefinition bd = new RootBeanDefinition();
    bd.setBeanClass(beanClass);// ww w  .  j a v  a2  s .  co  m
    // ??lazy init
    bd.setLazyInit(false);

    // id?id,idcontext
    String id = element.getAttribute("id");
    if ((id == null || id.length() == 0) && required) {
        String generatedBeanName = element.getAttribute("name");
        if (generatedBeanName == null || generatedBeanName.length() == 0) {
            generatedBeanName = element.getAttribute("class");
        }
        if (generatedBeanName == null || generatedBeanName.length() == 0) {
            generatedBeanName = beanClass.getName();
        }
        id = generatedBeanName;
        int counter = 2;
        while (parserContext.getRegistry().containsBeanDefinition(id)) {
            id = generatedBeanName + (counter++);
        }
    }
    if (id != null && id.length() > 0) {
        if (parserContext.getRegistry().containsBeanDefinition(id)) {
            throw new IllegalStateException("Duplicate spring bean id " + id);
        }
        parserContext.getRegistry().registerBeanDefinition(id, bd);
    }
    bd.getPropertyValues().addPropertyValue("id", id);
    if (ProtocolConfig.class.equals(beanClass)) {
        MotanNamespaceHandler.protocolDefineNames.add(id);

    } else if (RegistryConfig.class.equals(beanClass)) {
        MotanNamespaceHandler.registryDefineNames.add(id);

    } else if (BasicServiceInterfaceConfig.class.equals(beanClass)) {
        MotanNamespaceHandler.basicServiceConfigDefineNames.add(id);

    } else if (BasicRefererInterfaceConfig.class.equals(beanClass)) {
        MotanNamespaceHandler.basicRefererConfigDefineNames.add(id);

    } else if (ServiceConfigBean.class.equals(beanClass)) {
        String className = element.getAttribute("class");
        if (className != null && className.length() > 0) {
            RootBeanDefinition classDefinition = new RootBeanDefinition();
            classDefinition.setBeanClass(
                    Class.forName(className, true, Thread.currentThread().getContextClassLoader()));
            classDefinition.setLazyInit(false);
            parseProperties(element.getChildNodes(), classDefinition);
            bd.getPropertyValues().addPropertyValue("ref",
                    new BeanDefinitionHolder(classDefinition, id + "Impl"));
        }
    }

    Set<String> props = new HashSet<String>();
    ManagedMap parameters = null;
    // ??setbd
    for (Method setter : beanClass.getMethods()) {
        String name = setter.getName();
        // setXXX
        if (name.length() <= 3 || !name.startsWith("set") || !Modifier.isPublic(setter.getModifiers())
                || setter.getParameterTypes().length != 1) {
            continue;
        }
        String property = (name.substring(3, 4).toLowerCase() + name.substring(4)).replaceAll("_", "-");
        props.add(property);
        if ("id".equals(property)) {
            bd.getPropertyValues().addPropertyValue("id", id);
            continue;
        }
        String value = element.getAttribute(property);
        if ("methods".equals(property)) {
            parseMethods(id, element.getChildNodes(), bd, parserContext);
        }
        if (StringUtils.isBlank(value)) {
            continue;
        }
        value = value.trim();
        if (value.length() == 0) {
            continue;
        }
        Object reference;
        if ("ref".equals(property)) {
            if (parserContext.getRegistry().containsBeanDefinition(value)) {
                BeanDefinition refBean = parserContext.getRegistry().getBeanDefinition(value);
                if (!refBean.isSingleton()) {
                    throw new IllegalStateException(
                            "The exported service ref " + value + " must be singleton! Please set the " + value
                                    + " bean scope to singleton, eg: <bean id=\"" + value
                                    + "\" scope=\"singleton\" ...>");
                }
            }
            reference = new RuntimeBeanReference(value);
        } else if ("protocol".equals(property) && !StringUtils.isBlank(value)) {
            if (!value.contains(",")) {
                reference = new RuntimeBeanReference(value);
            } else {
                parseMultiRef("protocols", value, bd, parserContext);
                reference = null;
            }
        } else if ("registry".equals(property)) {
            parseMultiRef("registries", value, bd, parserContext);
            reference = null;
        } else if ("basicService".equals(property)) {
            reference = new RuntimeBeanReference(value);

        } else if ("basicReferer".equals(property)) {
            reference = new RuntimeBeanReference(value);

        } else if ("extConfig".equals(property)) {
            reference = new RuntimeBeanReference(value);
        } else {
            reference = new TypedStringValue(value);
        }

        if (reference != null) {
            bd.getPropertyValues().addPropertyValue(property, reference);
        }
    }
    if (ProtocolConfig.class.equals(beanClass)) {
        // protocolparameters?
        NamedNodeMap attributes = element.getAttributes();
        int len = attributes.getLength();
        for (int i = 0; i < len; i++) {
            Node node = attributes.item(i);
            String name = node.getLocalName();
            if (!props.contains(name)) {
                if (parameters == null) {
                    parameters = new ManagedMap();
                }
                String value = node.getNodeValue();
                parameters.put(name, new TypedStringValue(value, String.class));
            }
        }
        bd.getPropertyValues().addPropertyValue("parameters", parameters);
    }
    return bd;
}

From source file:org.cloudfoundry.reconfiguration.util.StandardPropertyAugmenterTest.java

@Test
public void existingTypedStringValue() {
    TypedStringValue tsv = new TypedStringValue("additional-key=additional-value");
    this.propertyValues.addPropertyValue(this.key, tsv);

    this.propertyAugmenter.augment(this.beanFactory, this.beanClass, this.key, this.additionalProperties);

    assertTrue(this.propertyValues.contains(this.key));
    assertContainsKey("additional-key");
}

From source file:org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityPostProcessor.java

/**
 * @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
 *///from   w  w  w .ja va  2  s  . com
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
    for (String bean : getSecurityBeanNames(beanFactory)) {
        if (beanFactory.containsBeanDefinition(bean)) {
            if (logger.isDebugEnabled()) {
                logger.debug("Adding RM method security definitions for " + bean);
            }

            BeanDefinition beanDef = beanFactory.getBeanDefinition(bean);
            PropertyValue beanValue = beanDef.getPropertyValues()
                    .getPropertyValue(PROP_OBJECT_DEFINITION_SOURCE);
            if (beanValue != null) {
                String beanStringValue = (String) ((TypedStringValue) beanValue.getValue()).getValue();
                String mergedStringValue = merge(beanStringValue);
                beanDef.getPropertyValues().addPropertyValue(PROP_OBJECT_DEFINITION_SOURCE,
                        new TypedStringValue(mergedStringValue));
            }
        }
    }
}

From source file:org.alfresco.repo.management.subsystems.LegacyConfigPostProcessor.java

/**
 * Given a bean name (assumed to implement {@link org.springframework.core.io.support.PropertiesLoaderSupport})
 * checks whether it already references the <code>global-properties</code> bean. If not, 'upgrades' the bean by
 * appending all additional resources it mentions in its <code>locations</code> property to
 * <code>globalPropertyLocations</code>, except for those resources mentioned in <code>newLocations</code>. A
 * reference to <code>global-properties</code> will then be added and the resource list in
 * <code>newLocations<code> will then become the new <code>locations</code> list for the bean.
 * /*w ww  . jav  a  2s  . com*/
 * @param beanFactory
 *            the bean factory
 * @param globalPropertyLocations
 *            the list of global property locations to be appended to
 * @param beanName
 *            the bean name
 * @param newLocations
 *            the new locations to be set on the bean
 * @return the mutable property values
 */
@SuppressWarnings("unchecked")
private MutablePropertyValues processLocations(ConfigurableListableBeanFactory beanFactory,
        Collection<Object> globalPropertyLocations, String beanName, String[] newLocations) {
    // Get the bean an check its existing properties value
    MutablePropertyValues beanProperties = beanFactory.getBeanDefinition(beanName).getPropertyValues();
    PropertyValue pv = beanProperties.getPropertyValue(LegacyConfigPostProcessor.PROPERTY_PROPERTIES);
    Object value;

    // If the properties value already references the global-properties bean, we have nothing else to do. Otherwise,
    // we have to 'upgrade' the bean definition.
    if (pv == null || (value = pv.getValue()) == null || !(value instanceof BeanReference)
            || ((BeanReference) value).getBeanName()
                    .equals(LegacyConfigPostProcessor.BEAN_NAME_GLOBAL_PROPERTIES)) {
        // Convert the array of new locations to a managed list of type string values, so that it is
        // compatible with a bean definition
        Collection<Object> newLocationList = new ManagedList(newLocations.length);
        if (newLocations != null && newLocations.length > 0) {
            for (String preserveLocation : newLocations) {
                newLocationList.add(new TypedStringValue(preserveLocation));
            }
        }

        // If there is currently a locations list, process it
        pv = beanProperties.getPropertyValue(LegacyConfigPostProcessor.PROPERTY_LOCATIONS);
        if (pv != null && (value = pv.getValue()) != null && value instanceof Collection) {
            Collection<Object> locations = (Collection<Object>) value;

            // Compute the set of locations that need to be added to globalPropertyLocations (preserving order) and
            // warn about each
            Set<Object> addedLocations = new LinkedHashSet<Object>(locations);
            addedLocations.removeAll(globalPropertyLocations);
            addedLocations.removeAll(newLocationList);

            for (Object location : addedLocations) {
                LegacyConfigPostProcessor.logger.warn("Legacy configuration detected: adding "
                        + (location instanceof TypedStringValue ? ((TypedStringValue) location).getValue()
                                : location.toString())
                        + " to global-properties definition");
                globalPropertyLocations.add(location);
            }

        }
        // Ensure the bean now references global-properties
        beanProperties.addPropertyValue(LegacyConfigPostProcessor.PROPERTY_PROPERTIES,
                new RuntimeBeanReference(LegacyConfigPostProcessor.BEAN_NAME_GLOBAL_PROPERTIES));

        // Ensure the new location list is now set on the bean
        if (newLocationList.size() > 0) {
            beanProperties.addPropertyValue(LegacyConfigPostProcessor.PROPERTY_LOCATIONS, newLocationList);
        } else {
            beanProperties.removePropertyValue(LegacyConfigPostProcessor.PROPERTY_LOCATIONS);
        }
    }
    return beanProperties;
}

From source file:org.eclipse.gemini.blueprint.blueprint.config.internal.BlueprintParser.java

private Object parsePropertyValue(Element ele, BeanDefinition bd, String propertyName) {
    String elementName = (propertyName != null) ? "<property> element for property '" + propertyName + "'"
            : "<constructor-arg> element";

    // Should only have one child element: ref, value, list, etc.
    NodeList nl = ele.getChildNodes();
    Element subElement = null;// w w w  . j  a va 2  s  .  c  o  m
    for (int i = 0; i < nl.getLength(); i++) {
        Node node = nl.item(i);
        if (node instanceof Element
                && !DomUtils.nodeNameEquals(node, BeanDefinitionParserDelegate.DESCRIPTION_ELEMENT)) {
            // Child element is what we're looking for.
            if (subElement != null) {
                error(elementName + " must not contain more than one sub-element", ele);
            } else {
                subElement = (Element) node;
            }
        }
    }

    boolean hasRefAttribute = ele.hasAttribute(BeanDefinitionParserDelegate.REF_ATTRIBUTE);
    boolean hasValueAttribute = ele.hasAttribute(BeanDefinitionParserDelegate.VALUE_ATTRIBUTE);
    if ((hasRefAttribute && hasValueAttribute)
            || ((hasRefAttribute || hasValueAttribute) && subElement != null)) {
        error(elementName
                + " is only allowed to contain either 'ref' attribute OR 'value' attribute OR sub-element",
                ele);
    }

    if (hasRefAttribute) {
        String refName = ele.getAttribute(BeanDefinitionParserDelegate.REF_ATTRIBUTE);
        if (!StringUtils.hasText(refName)) {
            error(elementName + " contains empty 'ref' attribute", ele);
        }
        RuntimeBeanReference ref = new RuntimeBeanReference(refName);
        ref.setSource(parserContext.extractSource(ele));
        return ref;
    } else if (hasValueAttribute) {
        TypedStringValue valueHolder = new TypedStringValue(
                ele.getAttribute(BeanDefinitionParserDelegate.VALUE_ATTRIBUTE));
        valueHolder.setSource(parserContext.extractSource(ele));
        return valueHolder;
    } else if (subElement != null) {
        return parsePropertySubElement(subElement, bd, null);
    } else {
        // Neither child element nor "ref" or "value" attribute found.
        error(elementName + " must specify a ref or value", ele);
        return null;
    }
}

From source file:org.eclipse.gemini.blueprint.blueprint.config.internal.BlueprintParser.java

/**
 * Parse a value, ref or collection sub-element of a property or constructor-arg element. This method is called from
 * several places to handle reusable elements such as idref, ref, null, value and so on.
 * //from   w  w  w. jav a  2  s  .  c o m
 * In fact, this method is the main reason why the BeanDefinitionParserDelegate is not used in full since the
 * element namespace becomes important as mixed rfc124/bean content can coexist.
 * 
 * @param ele subelement of property element; we don't know which yet
 * @param defaultValueType the default type (class name) for any <code>&lt;value&gt;</code> tag that might be
 * created
 */
private Object parsePropertySubElement(Element ele, BeanDefinition bd, String defaultValueType) {
    // skip other namespace
    String namespaceUri = ele.getNamespaceURI();

    // check Spring own namespace
    if (parserContext.getDelegate().isDefaultNamespace(namespaceUri)) {
        return parserContext.getDelegate().parsePropertySubElement(ele, bd);
    }
    // let the delegate handle other ns
    else if (!NAMESPACE_URI.equals(namespaceUri)) {
        return parserContext.getDelegate().parseCustomElement(ele);
    }

    // 
    else {
        if (DomUtils.nodeNameEquals(ele, BEAN)) {
            BeanDefinitionHolder bdHolder = parseComponentDefinitionElement(ele, bd);
            if (bdHolder != null) {
                bdHolder = ParsingUtils.decorateBeanDefinitionIfRequired(ele, bdHolder, parserContext);
            }
            return bdHolder;
        }

        if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.REF_ELEMENT)) {
            return parseRefElement(ele);
        } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.IDREF_ELEMENT)) {
            return parseIdRefElement(ele);
        } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.VALUE_ELEMENT)) {
            return parseValueElement(ele, defaultValueType);
        } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.NULL_ELEMENT)) {
            // It's a distinguished null value. Let's wrap it in a TypedStringValue
            // object in order to preserve the source location.
            TypedStringValue nullHolder = new TypedStringValue(null);
            nullHolder.setSource(parserContext.extractSource(ele));
            return nullHolder;
        } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.ARRAY_ELEMENT)) {
            return parseArrayElement(ele, bd);
        } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.LIST_ELEMENT)) {
            return parseListElement(ele, bd);
        } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.SET_ELEMENT)) {
            return parseSetElement(ele, bd);
        } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.MAP_ELEMENT)) {
            return parseMapElement(ele, bd);
        } else if (DomUtils.nodeNameEquals(ele, BeanDefinitionParserDelegate.PROPS_ELEMENT)) {
            return parsePropsElement(ele);
        }

        // maybe it's a nested service/reference/ref-list/ref-set
        return parserContext.getDelegate().parseCustomElement(ele, bd);
    }
}