• Spring源码学习相关记录


    Spring单例实现:

        protected Object getSingleton(String beanName, boolean allowEarlyReference) {
            Object singletonObject = this.singletonObjects.get(beanName);
            if (singletonObject == null && isSingletonCurrentlyInCreation(beanName)) {
                synchronized (this.singletonObjects) {
                    singletonObject = this.earlySingletonObjects.get(beanName);
                    if (singletonObject == null && allowEarlyReference) {
                        ObjectFactory<?> singletonFactory = this.singletonFactories.get(beanName);
                        if (singletonFactory != null) {
                            singletonObject = singletonFactory.getObject();
                            this.earlySingletonObjects.put(beanName, singletonObject);
                            this.singletonFactories.remove(beanName);
                        }
                    }
                }
            }
            return (singletonObject != NULL_OBJECT ? singletonObject : null);
        }

    Spring懒加载:

    private Map<String, Object> getHandlerMappings() {
            if (this.handlerMappings == null) {
                synchronized (this) {
                    if (this.handlerMappings == null) {
                        try {
                            Properties mappings =
                                    PropertiesLoaderUtils.loadAllProperties(this.handlerMappingsLocation, this.classLoader);
                            if (logger.isDebugEnabled()) {
                                logger.debug("Loaded NamespaceHandler mappings: " + mappings);
                            }
                            Map<String, Object> handlerMappings = new ConcurrentHashMap<String, Object>(mappings.size());
                            CollectionUtils.mergePropertiesIntoMap(mappings, handlerMappings);
                            this.handlerMappings = handlerMappings;
                        }
                        catch (IOException ex) {
                            throw new IllegalStateException(
                                    "Unable to load NamespaceHandler mappings from location [" + this.handlerMappingsLocation + "]", ex);
                        }
                    }
                }
            }
            return this.handlerMappings;
        }
  • 相关阅读:
    安装完openfire之后打不开的解决方案
    iOS中动画的简单使用
    iOS中的多线程及GCD
    iOS 架构模式-MVVM
    iOS
    iOS 下拉刷新 上拉加载实现原理
    iOS
    iOS 中的XML解析代码(SAX)
    iOS
    iOS中的网络请求 和 网络监测
  • 原文地址:https://www.cnblogs.com/caiyao/p/10141284.html
Copyright © 2020-2023  润新知