From the course: Spring: Framework in Depth
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
The destruction phase
- [Instructor] When your application begins to shut down, hopefully on purpose, you enter the destruction phase of the life cycle. Now, the destruction phase is really critical because this is when Spring itself goes out of context. And it begins when close is called on the ApplicationContext. So there is a method called close that you can call. Now, if you just shut your application down, close will be called as well in a roundabout way. Any @PreDestroy method is called when close is called on the ApplicationContext. And again, this is that life cycle method that gave you the last chance to do work before Spring itself goes out of scope. It's important to note that beans are not destroyed. This is Java. You can't destroy the beans anywhere. Only the garbage collector can do that. So beans are not destroyed. They're not de-referenced until close occurs. Then they are de-referenced and marked as available for garbage…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Why the lifecycle is so important3m 38s
-
The overall picture2m 25s
-
(Locked)
The init phase: Loading bean definitions2m 54s
-
(Locked)
Init: Bean factory post-processing3m 55s
-
(Locked)
Init: Bean instantiation3m
-
(Locked)
Init: Setters1m 54s
-
(Locked)
Init: Bean post-processing3m 25s
-
(Locked)
Init: Differences based on configuration2m 49s
-
(Locked)
The use phase1m 56s
-
(Locked)
The destruction phase2m 6s
-
(Locked)
-
-