zoukankan      html  css  js  c++  java
  • Spring源码解析之BeanFactory

    BeanFactory接口:

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

    完整的初始化方法及其标准顺序是:

    1. BeanNameAware's setBeanName
    2. BeanClassLoaderAware's setBeanClassLoader
    3. BeanFactoryAware's setBeanFactory
    4. ResourceLoaderAware's setResourceLoader (only applicable when running in an application context)
    5. ApplicationEventPublisherAware's setApplicationEventPublisher (only applicable when running in an application context)
    6. MessageSourceAware's setMessageSource (only applicable when running in an application context)
    7. ApplicationContextAware's setApplicationContext (only applicable when running in an application context)
    8. ServletContextAware's setServletContext (only applicable when running in a web application context)
    9. postProcessBeforeInitialization methods of BeanPostProcessors
    10. InitializingBean's afterPropertiesSet
    11. a custom init-method definition
    12. postProcessAfterInitialization methods of BeanPostProcessors

    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.
  • 相关阅读:
    python:推导式套路
    重大技术需求征集系统八稿开发进度(8)
    重大技术需求征集系统八稿开发进度(7)
    重大技术征集系统第八稿开发进度(6)
    hbase的基本操作
    重大技术征集系统八稿(5)
    重大技术八稿开发记录(4)
    重大技术八稿开发记录(3)
    重大技术八稿开发记录(2)
    重大技术八稿开发记录(1)
  • 原文地址:https://www.cnblogs.com/yaohuiqin/p/10435356.html
Copyright © 2011-2022 走看看