vishal lakhyani
vishal lakhyani

Reputation: 99

Where spring container will create all run time objects

As per Spring documentation it says that spring IOC container manages entire life cycle for beans.

My question is where the Spring container will create a new object? in JVM or where? Also how references of objects will be maintained.

Also below questions,

  1. For standalone application where those bean will be created?
  2. For WebApplication where those bean will be created?

I have gone through major of the Spring doc's but haven't found any clear idea on how object references are maintained.

Upvotes: 0

Views: 155

Answers (1)

dunni
dunni

Reputation: 44545

Since a Spring Boot application runs in a JVM, the objects are created there as well.

Spring keeps references to the beans in the application context. There are several concrete implementations of the ApplicationContext interface (depending on the type of the application), but in the end it comes down to a bunch of HashMaps, which hold the bean instances or information about how to create them, bean types etc. The most relevant class, if you're interested in implementation details, is IMO org.springframework.beans.factory.support.DefaultListableBeanFactory. This is used by all application context implementations to register beans, resolve them etc.

Upvotes: 2

Related Questions