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.
  • 相关阅读:
    HDU3461 Code Lock 并查集应用
    记录,待总结8
    HDU1325 Is It A Tree?
    函数指针总结
    记录,待总结6
    HDU1272 小希的迷宫 并查集
    记录,待总结10
    记录,待总结9
    C# 获取radiobutton的值
    解决idea控制台tomcat输出中文乱码
  • 原文地址:https://www.cnblogs.com/yaohuiqin/p/10435356.html
Copyright © 2011-2022 走看看