八股文-Spring

设计模式

Bean Lifcycle

Multiple lifecycle mechanisms configured for the same bean, with different initialization methods, are called as follows:

  • Methods annotated with @PostConstruct
  • afterPropertiesSet() as defined by the InitializingBean callback interface
  • A custom configured init() method
    Destroy methods are called in the same order:
  • Methods annotated with @PreDestroy
  • destroy() as defined by the DisposableBean callback interface
  • A custom configured destroy() method

ContextLoaderListener

ClassPathXmlApplicationContext

AbstractXmlApplicationContext.loadBeanDefinitions

AbstractApplicationContext

AbstractBeanFactory getBean