Spring IOC学习(2)——DefaultSingletonBeanRegistry

本文详细探讨了Spring框架中的DefaultSingletonBeanRegistry,它是Spring IoC容器中负责管理单例对象的核心组件。通过了解其工作原理,可以更好地掌握Spring的内部机制。
摘要由CSDN通过智能技术生成

DefaultSingletonBeanRegistry:提供单例对象管理能力

/**
  * Internal marker for a null singleton object:
  * used as marker value for concurrent Maps (which don't support null values).
  */
 protected static final Object NULL_OBJECT = new Object();


 /** Logger available to subclasses */
 protected final Log logger = LogFactory.getLog(getClass());

 /** Cache of singleton objects: bean name --> bean instance 
 * name->已经注册完成的单例对象
 */
 private final Map<String, Object> singletonObjects = new ConcurrentHashMap<String, Object>(256);

 /** Cache of singleton factories: bean name --> ObjectFactory 
 * name->对象工厂
 */
 private final Map<String, ObjectFactory<?>> singletonFactories = new HashMap<String, ObjectFactory<?>>(16);

 /** Cache of early singleton objects: bean name --> bean instance 
 * name->未创建完成,提前暴露的对象
 */
 private final Map<String, Object> earlySingletonObjects = new HashMap<String, Object>(16);

 /** Set of registered singletons, containing the bean names in registration order 
 * 已经完成注册的单例对象
 */
 private final Set<String> registeredSingletons = new LinkedHashSet<String>(256);

 /** Names of beans that are currently in creation 
 * 当前正在创建的单例对象
 */
 private final Set<String> singletonsCurrentlyInCreation =
   Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(16));

 /** Names of beans currently excluded from in creation checks 
 * 不进行“当前正在创建”检查的bean
 */
 private final Set<String> inCreationCheckExclusions =
   Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(16));

 /** List of suppressed Exceptions, available for associating related causes */
 private Set<Exception> suppressedExceptions;

 /** Flag that indicates whether we're currently within destroySingletons 
 * 容器关闭,正在销毁所有单例对象时为true
 */
 private boolean singletonsCurrentlyInDestruction = false;

 /
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值