Example usage for org.springframework.beans.factory.xml DocumentDefaultsDefinition setMerge

List of usage examples for org.springframework.beans.factory.xml DocumentDefaultsDefinition setMerge

Introduction

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

Prototype

public void setMerge(@Nullable String merge) 

Source Link

Document

Set the default merge setting for the document that's currently parsed.

Usage

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

/**
 * Populate the given DocumentDefaultsDefinition instance with the default lazy-init,
 * autowire, dependency check settings, init-method, destroy-method and merge settings.
 * Support nested 'beans' element use cases by falling back to <literal>parentDefaults</literal>
 * in case the defaults are not explicitly set locally.
 * @param defaults the defaults to populate
 * @param parentDefaults the parent BeanDefinitionParserDelegate (if any) defaults to fall back to
 * @param root the root element of the current bean definition document (or nested beans element)
 *//*from   ww  w  .  j  a va2  s .c  o  m*/
protected void populateDefaults(DocumentDefaultsDefinition defaults,
        @Nullable DocumentDefaultsDefinition parentDefaults, Element root) {
    String lazyInit = root.getAttribute(DEFAULT_LAZY_INIT_ATTRIBUTE);
    if (DEFAULT_VALUE.equals(lazyInit)) {
        // Potentially inherited from outer <beans> sections, otherwise falling back to false.
        lazyInit = (parentDefaults != null ? parentDefaults.getLazyInit() : FALSE_VALUE);
    }
    defaults.setLazyInit(lazyInit);

    String merge = root.getAttribute(DEFAULT_MERGE_ATTRIBUTE);
    if (DEFAULT_VALUE.equals(merge)) {
        // Potentially inherited from outer <beans> sections, otherwise falling back to false.
        merge = (parentDefaults != null ? parentDefaults.getMerge() : FALSE_VALUE);
    }
    defaults.setMerge(merge);

    String autowire = root.getAttribute(DEFAULT_AUTOWIRE_ATTRIBUTE);
    if (DEFAULT_VALUE.equals(autowire)) {
        // Potentially inherited from outer <beans> sections, otherwise falling back to 'no'.
        autowire = (parentDefaults != null ? parentDefaults.getAutowire() : AUTOWIRE_NO_VALUE);
    }
    defaults.setAutowire(autowire);

    if (root.hasAttribute(DEFAULT_AUTOWIRE_CANDIDATES_ATTRIBUTE)) {
        defaults.setAutowireCandidates(root.getAttribute(DEFAULT_AUTOWIRE_CANDIDATES_ATTRIBUTE));
    } else if (parentDefaults != null) {
        defaults.setAutowireCandidates(parentDefaults.getAutowireCandidates());
    }

    if (root.hasAttribute(DEFAULT_INIT_METHOD_ATTRIBUTE)) {
        defaults.setInitMethod(root.getAttribute(DEFAULT_INIT_METHOD_ATTRIBUTE));
    } else if (parentDefaults != null) {
        defaults.setInitMethod(parentDefaults.getInitMethod());
    }

    if (root.hasAttribute(DEFAULT_DESTROY_METHOD_ATTRIBUTE)) {
        defaults.setDestroyMethod(root.getAttribute(DEFAULT_DESTROY_METHOD_ATTRIBUTE));
    } else if (parentDefaults != null) {
        defaults.setDestroyMethod(parentDefaults.getDestroyMethod());
    }

    defaults.setSource(this.readerContext.extractSource(root));
}