Bean Scopes and Lifecycle Callbacks

Bean scopes and lifecycle callbacks: how many instances of a bean exist, how long each lives, and who cleans it up.

  • 7 cards
  • 4 questions
  • About 8 min
  • Intermediate to Advanced
Share

Bean scopes, which decide how many instances of a bean exist and how long each one lives, and the two lifecycle callbacks that run when a bean starts and stops. Most beans are singletons and that is invisible, until a singleton holds state that two requests can both reach. It covers singleton and prototype scope, the shared-state mistake, @PostConstruct and @PreDestroy, and the scoped proxy a request-scoped bean needs before a singleton can use it. It leaves out session scope and writing custom scopes.

Contents

7 cardsnot started