Example usage for org.springframework.beans.factory.xml BeanDefinitionParserDelegate BEANS_NAMESPACE_URI

List of usage examples for org.springframework.beans.factory.xml BeanDefinitionParserDelegate BEANS_NAMESPACE_URI

Introduction

In this page you can find the example usage for org.springframework.beans.factory.xml BeanDefinitionParserDelegate BEANS_NAMESPACE_URI.

Prototype

String BEANS_NAMESPACE_URI

To view the source code for org.springframework.beans.factory.xml BeanDefinitionParserDelegate BEANS_NAMESPACE_URI.

Click Source Link

Usage

From source file:org.jboss.windup.config.spring.namespace.java.SpringNamespaceHandlerUtil.java

public static BeanDefinition resolveBeanDefinition(BeanDefinition beanDef, Element element,
        ParserContext context) {/*from w  w w.  jav  a2  s .  c om*/
    BeanDefinitionParserDelegate delegate = context.getDelegate();
    String namespace = element.getNamespaceURI();

    // check to see whether it is the default Spring bean decorator...
    if (StringUtils.equals(namespace, BeanDefinitionParserDelegate.BEANS_NAMESPACE_URI)) {
        BeanDefinitionHolder holder = delegate.parseBeanDefinitionElement(element, beanDef);
        return holder.getBeanDefinition();
    }

    // otherwise, see if it is supported based on our namespace resolver...
    NamespaceHandler namespaceHandler = delegate.getReaderContext().getNamespaceHandlerResolver()
            .resolve(namespace);
    if (namespaceHandler == null) {
        throw new FatalBeanException("Unable to find parser for bean with namespace: " + namespace);
    }

    return namespaceHandler.parse(element, new ParserContext(delegate.getReaderContext(), delegate, beanDef));
}

From source file:org.solmix.runtime.support.spring.AbstractBeanDefinitionParser.java

protected void firstChildAsProperty(Element element, ParserContext ctx, BeanDefinitionBuilder bean,
        String propertyName) {/* w  w  w. jav  a2  s .c o  m*/
    Element first = getFirstChild(element);
    if (first == null) {
        throw new IllegalStateException(propertyName + " property must have child elements!");
    }
    String id;
    BeanDefinition child;
    if (first.getNamespaceURI().equals(BeanDefinitionParserDelegate.BEANS_NAMESPACE_URI)) {
        String name = first.getLocalName();
        if ("ref".equals(name)) {
            id = first.getAttribute("bean");
            if (id == null) {
                throw new IllegalStateException("<ref> elements must have a \"bean\" attribute!");
            }
            bean.addPropertyReference(propertyName, id);
            return;
        } else if ("bean".equals(name)) {
            BeanDefinitionHolder bdh = ctx.getDelegate().parseBeanDefinitionElement(first);
            child = bdh.getBeanDefinition();
            bean.addPropertyValue(propertyName, child);
            return;
        } else {
            throw new UnsupportedOperationException("Elements with the name " + name + " are not currently "
                    + "supported as sub elements of " + element.getLocalName());
        }
    }
    child = ctx.getDelegate().parseCustomElement(first, bean.getBeanDefinition());
    bean.addPropertyValue(propertyName, child);
}

From source file:org.mule.config.spring.util.SpringXMLUtils.java

public static boolean isBeansNamespace(Element element) {
    String ns = element.getNamespaceURI();
    return ns != null && ns.equals(BeanDefinitionParserDelegate.BEANS_NAMESPACE_URI);
}