Example usage for org.springframework.beans.factory.support AbstractBeanDefinition setDescription

List of usage examples for org.springframework.beans.factory.support AbstractBeanDefinition setDescription

Introduction

In this page you can find the example usage for org.springframework.beans.factory.support AbstractBeanDefinition setDescription.

Prototype

@Override
public void setDescription(@Nullable String description) 

Source Link

Document

Set a human-readable description of this bean definition.

Usage

From source file:org.jdal.beans.CustomBeanDefinitionParser.java

/**
 * Parse bean like a real bean definition.
 * @param ele element/*from w w  w . j a v  a 2 s. co  m*/
 * @param parserContext parserContext
 * @param builder builder
 */
protected void parseBeanDefinition(Element ele, ParserContext parserContext, BeanDefinitionBuilder builder) {
    BeanDefinitionParserDelegate delegate = parserContext.getDelegate();
    AbstractBeanDefinition bd = builder.getRawBeanDefinition();
    XmlReaderContext reader = parserContext.getReaderContext();

    try {
        delegate.parseBeanDefinitionAttributes(ele, beanName, null, bd);
        bd.setDescription(DomUtils.getChildElementValueByTagName(ele, "description"));

        delegate.parseMetaElements(ele, bd);
        delegate.parseLookupOverrideSubElements(ele, bd.getMethodOverrides());
        delegate.parseReplacedMethodSubElements(ele, bd.getMethodOverrides());

        delegate.parseConstructorArgElements(ele, bd);
        delegate.parsePropertyElements(ele, bd);
        delegate.parseQualifierElements(ele, bd);

    } catch (NoClassDefFoundError err) {
        reader.error("Class that bean class [" + this.beanClass + "] depends on not found", ele, err);
    } catch (Throwable ex) {
        reader.error("Unexpected failure during bean definition parsing", ele, ex);
    }

}

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

/**
 * Parse the bean definition itself, without regard to name or aliases. May return <code>null</code> if problems
 * occurred during the parse of the bean definition.
 *///from   w w  w.  j a v a 2 s. c  o  m
private AbstractBeanDefinition parseBeanDefinitionElement(Element ele, String beanName,
        BeanDefinition containingBean) {

    this.parseState.push(new BeanEntry(beanName));

    String className = null;
    if (ele.hasAttribute(BeanDefinitionParserDelegate.CLASS_ATTRIBUTE)) {
        className = ele.getAttribute(BeanDefinitionParserDelegate.CLASS_ATTRIBUTE).trim();
    }

    try {
        AbstractBeanDefinition beanDefinition = BeanDefinitionReaderUtils.createBeanDefinition(null, className,
                parserContext.getReaderContext().getBeanClassLoader());

        // some early validation
        String activation = ele.getAttribute(LAZY_INIT_ATTR);
        String scope = ele.getAttribute(BeanDefinitionParserDelegate.SCOPE_ATTRIBUTE);

        if (EAGER_INIT_VALUE.equals(activation) && BeanDefinition.SCOPE_PROTOTYPE.equals(scope)) {
            error("Prototype beans cannot be eagerly activated", ele);
        }

        // add marker to indicate that the scope was present
        if (StringUtils.hasText(scope)) {
            beanDefinition.setAttribute(DECLARED_SCOPE, Boolean.TRUE);
        }

        // parse attributes
        parseAttributes(ele, beanName, beanDefinition);

        // inner beans get a predefined scope in RFC 124
        if (containingBean != null) {
            beanDefinition.setLazyInit(true);
            beanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
        }

        // parse description
        beanDefinition.setDescription(
                DomUtils.getChildElementValueByTagName(ele, BeanDefinitionParserDelegate.DESCRIPTION_ELEMENT));

        parseConstructorArgElements(ele, beanDefinition);
        parsePropertyElements(ele, beanDefinition);

        beanDefinition.setResource(parserContext.getReaderContext().getResource());
        beanDefinition.setSource(extractSource(ele));

        return beanDefinition;
    } catch (ClassNotFoundException ex) {
        error("Bean class [" + className + "] not found", ele, ex);
    } catch (NoClassDefFoundError err) {
        error("Class that bean class [" + className + "] depends on not found", ele, err);
    } catch (Throwable ex) {
        error("Unexpected failure during bean definition parsing", ele, ex);
    } finally {
        this.parseState.pop();
    }

    return null;
}

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

/**
 * Parse the bean definition itself, without regard to name or aliases. May return
 * {@code null} if problems occurred during the parsing of the bean definition.
 *//*from w w  w  .ja  va2  s . co m*/
@Nullable
public AbstractBeanDefinition parseBeanDefinitionElement(Element ele, String beanName,
        @Nullable BeanDefinition containingBean) {

    this.parseState.push(new BeanEntry(beanName));

    String className = null;
    if (ele.hasAttribute(CLASS_ATTRIBUTE)) {
        className = ele.getAttribute(CLASS_ATTRIBUTE).trim();
    }
    String parent = null;
    if (ele.hasAttribute(PARENT_ATTRIBUTE)) {
        parent = ele.getAttribute(PARENT_ATTRIBUTE);
    }

    try {
        AbstractBeanDefinition bd = createBeanDefinition(className, parent);

        parseBeanDefinitionAttributes(ele, beanName, containingBean, bd);
        bd.setDescription(DomUtils.getChildElementValueByTagName(ele, DESCRIPTION_ELEMENT));

        parseMetaElements(ele, bd);
        parseLookupOverrideSubElements(ele, bd.getMethodOverrides());
        parseReplacedMethodSubElements(ele, bd.getMethodOverrides());

        parseConstructorArgElements(ele, bd);
        parsePropertyElements(ele, bd);
        parseQualifierElements(ele, bd);

        bd.setResource(this.readerContext.getResource());
        bd.setSource(extractSource(ele));

        return bd;
    } catch (ClassNotFoundException ex) {
        error("Bean class [" + className + "] not found", ele, ex);
    } catch (NoClassDefFoundError err) {
        error("Class that bean class [" + className + "] depends on not found", ele, err);
    } catch (Throwable ex) {
        error("Unexpected failure during bean definition parsing", ele, ex);
    } finally {
        this.parseState.pop();
    }

    return null;
}