In bean creation lifecycle we have:

– Instatiation: creating the bean instance

– Populate properties: injection of bean’s properties

– Set Bean name: if bean implements BeanNameAware then call setBeanName()

– Set bean factory: if bean implements BeanFactoryAware, call setBeanFactory()

– Set application context: if bean implements ApplicationContextAware, call setApplicationContext()

– PostProcess: if there are any BeanPostProcessors, call their postProcessBeforeInitialization()

– Initialize bean: if bean implements InitializingBean, call afterPropertiesSet(). If bean has a custom init method, call it. @PostConstruct annotated methods will be called where InitializingBean.afterPropertiesSet() would be.

– Postprocess: if there are any BeanPostProcessors, call their postProcessAfterInitialization()

Advertisements