zoukankan      html  css  js  c++  java
  • Spring源码追踪2——xml解析入口

    解析xml节点入口

    org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(Element root)

    protected void doRegisterBeanDefinitions(Element root) {
        // Any nested <beans> elements will cause recursion in this method. In
        // order to propagate and preserve <beans> default-* attributes correctly,
        // keep track of the current (parent) delegate, which may be null. Create
        // the new (child) delegate with a reference to the parent for fallback purposes,
        // then ultimately reset this.delegate back to its original (parent) reference.
        // this behavior emulates a stack of delegates without actually necessitating one.
        BeanDefinitionParserDelegate parent = this.delegate;
        this.delegate = createDelegate(this.readerContext, root, parent);
    
        if (this.delegate.isDefaultNamespace(root)) {
            String profileSpec = root.getAttribute(PROFILE_ATTRIBUTE);
            if (StringUtils.hasText(profileSpec)) {
                Assert.state(this.environment != null, "Environment must be set for evaluating profiles");
                String[] specifiedProfiles = StringUtils.tokenizeToStringArray(
                        profileSpec, BeanDefinitionParserDelegate.MULTI_VALUE_ATTRIBUTE_DELIMITERS);
                if (!this.environment.acceptsProfiles(specifiedProfiles)) {
                    return;
                }
            }
        }
    
        preProcessXml(root);
        parseBeanDefinitions(root, this.delegate);
        postProcessXml(root);
    
        this.delegate = parent;
    }

     继续往下追踪,parseCustomElement是解析自定义的元素节点,如<aop:aspectj-autoproxy />

    自定义标签对应类查找

    classpath下面的/META-INF/spring.handlers属性文件

    (见:http://my.oschina.net/haogrgr/blog/308199

  • 相关阅读:
    MyBatis中Like语句使用总结
    使用dom4j解析xml为json对象
    实体类里布尔类型在数据库里可以用整型映射
    Java枚举根据key获取value
    Oracle和Mysql中mybatis模糊匹配查询区别
    解决3 字节的 UTF-8 序列的字节 3 无效
    git上传代码到github
    OpenShift 3.11离线环境的jenkins演示
    OpenShift下的JVM监控
    OpenShift 4.1 演示
  • 原文地址:https://www.cnblogs.com/chanedi/p/4142748.html
Copyright © 2011-2022 走看看