Spring Framework - Bean - LOG.INFO

본 포스트는 ‘John Thompson’의 ‘Spring Framework Beginner to Guru’강의를 바탕으로 공부 목적으로 정리하고자 작성하였습니다.

Spring Bean Lifecycle

Create

  1. Instatntiate
  2. Popular Properties
  3. setBeanName of BeanNameAware
  4. setBeanFactory of BeanFactoryAware
  5. setApplicationContext of ApplicationContextAware
  6. Preinitialization (BeanPostProcessors)
  7. afterPropertiesSet of initializingBeans
  8. Custom Init Method
  9. Post Initialization (BeanPostProcessors)
  10. Finally! Bean Ready to Use!

Terminate

  1. Container Shutdown
  2. Disposable Bean’s destroy()
  3. Call custom destroy method

사용되는 Classes 또는 Interfaces

  • Aware(interface) : Spring의 infrastructure에 접근할 때 사용
    • Spring에는 14개의 Aware Interface가 있음
  • BeanNameAware
  • BeanFactoryAware
  • ApplicationContextAware
  • BeanPostProcessor(Interface) (실제 개발에 잘 사용하진 않음)
    • postProcessBeforeInitialization : Bean 초기화 전에 실행
    • postProcessAfterInitialization : Bean 초기화 후에 실행