From the course: Spring: Framework in Depth

The overall picture

From the course: Spring: Framework in Depth

Start my 1-month free trial

The overall picture

- [Instructor] So now it's time to dig into the lifecycle as a whole by starting with an overview. There are three primary phases of the Spring lifecycle, and we're going to spend most of our time talking about the first. That first is the initialization phase, and it by far is the most complex and quite frankly the most interesting of all of the lifecycle elements. While in reality it is one of the shortest phases in chronological time of the three, it is really where we can impact the behavior of our application the most. The next phase is the use phase. The largest majority of time is actually spent in this phase, but most of the interaction with the Spring IOC container here is behind-the-scenes. You may be using abstractions from Spring, but during the use phase most of the work with the framework is through proxies applied during the previous or initialization phase. And the final phase is the destruction phase which of course occurs when the ApplicationContext starts to close by the calling of the close method on it. Now again, we're going to spend most of our time talking about the initialization phase, so let's take a look at it from a high level now. The initialization phase begins when the ApplicationContext itself is created. This can be done as in our example manually or via runtime like an application server. It is further broken down into two phases. The setup of the bean factory via its initializations is the first part. The second is the bean initialization itself and instantiation phase where your bean objects are actually created and then managed by the framework. So we're going to take a look at this phase as an overview level. So what you'll see is we have these first two parts which are the loading of the bean definitions. So this is when the bean factory itself is created and all of our components come in. Then we go through each bean in the bean factory in order, we instantiate the bean, we call the setters on the bean, and then we do some processing. And we're going to talk about each of these in more depth. And after all of this is done, our application is ready to use. So let's jump into that first part of the initialization phase.

Contents