VB_
VB_

Reputation: 45702

Spring callbacks I can handle

In Spring docummentation mentioned many lifecycle steps: both for container and bean (see pictures below). But when I started to look for annotations (interfaces to implement) I couldn't find anything except of:

  1. @PostConstruct and @PreDestroy callacks
  2. Custom BeanPostProcessor implementation
  3. Custom BeanFactoryPostProcessor implementation

If I correctly understand those pictures, I can use:

Questions:

If I can use only 3 callbacks of container and bean lifecycle.. What is the information below for? I mean why I should know all those lifecycle steps if I can't profit from them. May be I forgot some callbacks that I can use?

Container lifecycle: enter image description here

Bean lyfecycle: enter image description here

Upvotes: 0

Views: 392

Answers (1)

Adam Dyga
Adam Dyga

Reputation: 8926

I think you missed all the *Aware intefaces, which are mentioned in the diagram (mainly from org.springframework.beans.factory package):

  • BeanNameAware
  • BeanFactoryAware
  • ApplicationContextAware
  • InitializingBean
  • DisposableBean

Whenever your bean implements one of those interfaces, Spring will call their methods at corresponding lifecycle step.

Upvotes: 2

Related Questions