Bean lifecycle

2018-07-03 16:47 更新
  1. Instantiate - 容器在 XML 文件里找到定義并實(shí)例化它們

  1. Populate properties - 使用 DI 填充屬性

  1. Set Bean Name - If the bean implements BeanNameAware interface, spring passes the bean's id to setBeanName() method.

  1. Set Bean factory - If Bean implements BeanFactoryAware interface, spring passes the beanfactory to setBeanFactory() method.

  1. Pre Initialization - 也叫 postprocess. Spring 調(diào)用 postProcesserBeforeInitialization() 方法.

  1. Initialize beans - If the bean implements IntializingBean,its afterPropertySet() method is called. If the bean has init method declaration, the specified initialization method is called.

  1. Post Initialization - 調(diào)用 postProcessAfterInitialization() 方法

  1. Ready to use - 現(xiàn)在可以用它們了.

  1. Destroy - If the bean implements DisposableBean , it will call the destroy() method .
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號