zoukankan      html  css  js  c++  java
  • RefreshScope

    What is RefreshScope ? 

       RefreshScope(org.springframework.cloud.context.scope.refresh)是spring cloud提供的一种特殊的scope实现,用来实现配置、实例热加载。 RefreshScope继承关系如下所示
     

     

     

     Scope -> GenericScope -> RefreshScope,Scope是Spring2.0开始有的概念,主要是用于定义spring的注入范围。GenericScope 是 一个通用Scope实现。

    2. RefreshScope实现原理

    要想了解RefreshScope的实现原理,首先要了解Scope在Springboot生命周期中涉及到的功能点

     2.1 Scope在创建Bean实例

    AbstractBeanFactory#doGetBean
    此方法返回一个Bean对象
      /*
         * Return an instance, which may be shared or independent, of the specified bean.
         */
        protected <T> T doGetBean(...) {
            final String beanName = transformedBeanName(name);
            Object bean;
            // Eagerly check singleton cache for manually registered singletons.
            Object sharedInstance = getSingleton(beanName);
            if (sharedInstance != null && args == null) {
                ...
                bean = getObjectForBeanInstance(sharedInstance, name, beanName, null);
            }
    
        }else {
            // Fail if we're already creating this bean instance:
            // We're assumably within a circular reference.
            ...
            // Check if bean definition exists in this factory.
            ...
            // Guarantee initialization of beans that the current bean depends on.
            ....
            //Create bean instance.
            if (mbd.isSingleton()) {
            ...
            } else if (mbd.isPrototype())
                ...
    
            {
                String scopeName = mbd.getScope();
                final Scope scope = this.scopes.get(scopeName);
                Object scopedInstance = scope.get(beanName, new ObjectFactory<Object>() {...
                });
            ...
            }
            ...
        }
    

      

  • 相关阅读:
    局域网搭建https局域网
    在内部局域网内搭建HTTPs
    在局域网内实现https安全访问
    http网站转换成https网站
    iis6 和iis7s上整个网站重定向
    我们在部署 HTTPS 网站时,该如何选择SSL证书?
    HTML:几个常见的列表标签
    HTML:基本的标签
    iOS: 字体样式
    iOS: 首次使用App时,显示半透明新手指引
  • 原文地址:https://www.cnblogs.com/NathanYang/p/13813143.html
Copyright © 2011-2022 走看看