Spring源码解析之BeanFactory

BeanFactory接口:

  用于访问SpringBean容器的根接口,这个接口是由持有许多bean定义的对象实现的,每个定义都由一个字符串名称唯一标识。根据bean定义,工厂将返回包含对象的独立实例(原型设计模式)或单个共享实例(与工厂范围内的单例实例为单例的单例设计模式相比,这是一种更好的选择)。BeanFactory是应用程序组件的中心注册表,并集中应用程序组件的配置。

String[] getAliases(String name) 
          Return the aliases for the given bean name, if any.
<T> T
getBean(Class<T> requiredType) 
          Return the bean instance that uniquely matches the given object type, if any.
 Object getBean(String name) 
          Return an instance, which may be shared or independent, of the specified bean.
<T> T
getBean(String name, Class<T> requiredType) 
          Return an instance, which may be shared or independent, of the specified bean.
 Object getBean(String name, Object... args) 
          Return an instance, which may be shared or independent, of the specified bean.
 Class<?> getType(String name) 
          Determine the type of the bean with the given name.
 boolean isPrototype(String name) 
          Is this bean a prototype? That is, will getBean(java.lang.String) always return independent instances?
 boolean isSingleton(String name) 
          Is this bean a shared singleton? That is, will getBean(java.lang.String) always return the same instance?
 boolean isTypeMatch(String name, Class<?> targetType) 
          Check whether the bean with the given name matches the specified type.

猜你喜欢

转载自www.cnblogs.com/yaohuiqin/p/10435356.html