Spring单例模式

Spring单例模式的核心使用注册表实现。如下:


	/** Cache of singleton objects: bean name --> bean instance */
	/** 已经在缓存里的单例对象实例,使用ConcurrentHashMap存储。 */
	private final Map<String, Object> singletonObjects = new ConcurrentHashMap<>(256);

	/** Cache of singleton factories: bean name --> ObjectFactory */
	/** 已经在缓存里的单例对象工厂 */
	private final Map<String, ObjectFactory<?>> singletonFactories = new HashMap<>(16);

	/** Cache of early singleton objects: bean name --> bean instance */
	/** 用于解析循环引用 */
	private final Map<String, Object> earlySingletonObjects = new HashMap<>(16);

	/** Set of registered singletons, containing the bean names in registration order */
	/** 当前已经注册的单例对象实例的name的集合 */
	private final Set<String> registeredSingletons = new LinkedHashSet<>(<

你可能感兴趣的:(Java,Spring,spring,java,设计模式,ioc,bean)