All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.contributions.mapped.MappedContributionBeanDefinitionParser Maven / Gradle / Ivy

Go to download

This project adds a so called contribution mechanism (like known from Tapestry IOC or Eclipse Plugins) for configuration and extension of services to the Spring project.

There is a newer version: 2.0.0
Show newest version
package org.springframework.contributions.mapped;

import java.util.Map;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.MapFactoryBean;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;

/**
 * Parser for mapped contribution bean definitions.
 *
 * @author Christian Köberl
 */
public class MappedContributionBeanDefinitionParser implements BeanDefinitionParser
{
    /**
     * {@inheritDoc}
     */
    @SuppressWarnings("rawtypes")
    public BeanDefinition parse(Element element, ParserContext parserContext)
    {
        String contributionName = element.getAttribute("to");
        BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(MapFactoryBean.class);

        element.setAttribute("merge", "true");
        Map parsedMap = parserContext.getDelegate().parseMapElement(element, builder.getRawBeanDefinition());

        return MappedContributionUtils.addContribution(contributionName, parsedMap, parserContext.getRegistry());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy