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     }
  • 相关阅读:
    11.变分推断
    10.高斯混合模型GMM
    9.EM 算法
    8.指数族分布
    7.概率图模型(表示/推断/学习)
    6.核方法
    二分查找
    2.3 数据结构---数组(连续)
    C#开发Windows服务的基础代码
    C#与C++之间类型的对应{转}
  • 原文地址:https://www.cnblogs.com/mjorcen/p/3649548.html
Copyright © 2011-2022 走看看