org.springframework.contributions.ordered.OrderedContributionBeanDefinitionParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-contributions Show documentation
Show all versions of spring-contributions Show documentation
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.
package org.springframework.contributions.ordered;
import static org.springframework.contributions.ContributionsNamespaceHandler.CONTRIBUTION_NAMESPACE;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
/**
* Parses contribution
tags in Spring XML config.
* @author Christian Köberl
*/
public class OrderedContributionBeanDefinitionParser implements BeanDefinitionParser
{
/**
* {@inheritDoc}
*/
public BeanDefinition parse(final Element element, final ParserContext parserContext)
{
String contributionName = element.getAttribute("to");
NodeList entryList = element.getElementsByTagNameNS(CONTRIBUTION_NAMESPACE, "entry");
List beans = new ArrayList();
for (int i = 0; i < entryList.getLength(); i++)
{
Element entry = (Element) entryList.item(i);
String name = entry.getAttribute("name");
String constraints = entry.getAttribute("constraints");
Object beanValueOrReference = parserContext.getDelegate().parsePropertyValue(entry, null, name);
beans.add(new OrderedContributionBeenContext(name, beanValueOrReference, constraints));
}
return OrderContributionUtils.parse(contributionName, beans, parserContext.getRegistry());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy