zoukankan      html  css  js  c++  java
  • 4.1 spring-alias 标签的解析;

      对于之前漫长的,最核心的Bean标签的解析就没什么好讲的了,

    首先看看使用方法:

    <bean id="car" name="cat0" class="entity.CarFactoryBean">
            <property name="carInfo" value="超级跑车,400,2000000" />
        </bean>
        <alias name="car" alias="cat1,cat2" />
        <alias name="car" alias="cat3,cat4" />

    解析过程如下:

     1     /**
     2      * Process the given alias element, registering the alias with the registry.
     3      */
     4     protected void processAliasRegistration(Element ele) {
     5         // 获取beanName
     6         String name = ele.getAttribute(NAME_ATTRIBUTE);
     7         // 获取alias
     8         String alias = ele.getAttribute(ALIAS_ATTRIBUTE);
     9         boolean valid = true;
    10         if (!StringUtils.hasText(name)) {
    11             getReaderContext().error("Name must not be empty", ele);
    12             valid = false;
    13         }
    14         if (!StringUtils.hasText(alias)) {
    15             getReaderContext().error("Alias must not be empty", ele);
    16             valid = false;
    17         }
    18         if (valid) {
    19             try {
    20                 // 注册alias
    21                 getReaderContext().getRegistry().registerAlias(name, alias);
    22             }
    23             catch (Exception ex) {
    24                 getReaderContext().error(
    25                         "Failed to register alias '" + alias + "' for bean with name '"
    26                                 + name + "'", ele, ex);
    27             }
    28             // 通知别名监听器
    29             getReaderContext().fireAliasRegistered(name, alias, extractSource(ele));
    30         }
    31     }
  • 相关阅读:
    ubuntu下安装eclipse
    UTC时间、GMT时间、本地时间、Unix时间戳
    [转]mysql使用关键字作为列名的处理方式
    mysql日期格式化
    ssh远程登陆看不到用户名和主机名
    ssh以root用户远程登录失败
    PowerBI发布到网页
    视图是否有主键的问题
    select count(*)和select count(1)
    PPT产品的重要性
  • 原文地址:https://www.cnblogs.com/mjorcen/p/3649548.html
Copyright © 2011-2022 走看看