zoukankan      html  css  js  c++  java
  • SpringMVC源码阅读(三)

    先理一下Bean的初始化路线

    org.springframework.beans.factory.support.AbstractBeanDefinitionReader

    public int loadBeanDefinitions(Resource... resources) throws BeanDefinitionStoreException
    {
        Assert.notNull(resources, "Resource array must not be null");
        int counter = 0;
        for (Resource resource : resources) {
          counter += loadBeanDefinitions(resource);
        }
        return counter;
    }
    

    org.springframework.beans.factory.xml.XmlBeanDefinitionReader

    public int loadBeanDefinitions(Resource resource)
        throws BeanDefinitionStoreException
      {
        return loadBeanDefinitions(new EncodedResource(resource));
      }
    
    protected int doLoadBeanDefinitions(InputSource inputSource, Resource resource)
        throws BeanDefinitionStoreException
      {
        try
        {
          int validationMode = getValidationModeForResource(resource);
          Document doc = this.documentLoader.loadDocument(inputSource, getEntityResolver(), this.errorHandler, validationMode, isNamespaceAware());
          
          return registerBeanDefinitions(doc, resource);
        }
        catch (BeanDefinitionStoreException ex) {
          throw ex;
        }
        catch (SAXParseException ex) {
          throw new XmlBeanDefinitionStoreException(resource.getDescription(), "Line " + ex.getLineNumber() + " in XML document from " + resource + " is invalid", ex);
        }
        catch (SAXException ex)
        {
          throw new XmlBeanDefinitionStoreException(resource.getDescription(), "XML document from " + resource + " is invalid", ex);
        }
        catch (ParserConfigurationException ex)
        {
          throw new BeanDefinitionStoreException(resource.getDescription(), "Parser configuration exception parsing XML from " + resource, ex);
        }
        catch (IOException ex)
        {
          throw new BeanDefinitionStoreException(resource.getDescription(), "IOException parsing XML document from " + resource, ex);
        }
        catch (Throwable ex)
        {
          throw new BeanDefinitionStoreException(resource.getDescription(), "Unexpected exception parsing XML document from " + resource, ex);
        }
      }
    

      

    org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader

     protected void parseBeanDefinitions(Element root, BeanDefinitionParserDelegate delegate)
      {
        if (delegate.isDefaultNamespace(root)) {
          NodeList nl = root.getChildNodes();
          for (int i = 0; i < nl.getLength(); i++) {
            Node node = nl.item(i);
            if ((node instanceof Element)) {
              Element ele = (Element)node;
              if (delegate.isDefaultNamespace(ele)) {
                parseDefaultElement(ele, delegate);
              }
              else {
                delegate.parseCustomElement(ele);
              }
            }
          }
        }
        else {
          delegate.parseCustomElement(root);
        }
      }
    

      

  • 相关阅读:
    对虚机设备Bridge ,Vlan, VETH, TAP详细介绍
    DevStack部署Openstack环境
    Ubuntu配置 PPTP 服务器端
    Ubuntu 配置PPTP客户端
    Git学习笔记
    Mysql安装随记,整理内容来源网络
    GitHub访问慢的优化处理
    NetCore部署到Linux服务器+Supervisor的步骤及过程中踩过的坑
    JavaScript的定时器如何先触发一次再延时
    在实现文本框只能输入数字和小数点的基础上实现了价格样式(保留两位小数)
  • 原文地址:https://www.cnblogs.com/wuxinliulei/p/5067985.html
Copyright © 2011-2022 走看看