Spring Core Framework - Where are the beans hold?

I am a junior Java developer and I am reading the spring documentation from spring.io. I read that every bean that gets registered in the *.xml file that spring uses to resolve dependencies is declared using <bean> </bean> tags.

My question is: In which data structure are the beans hold after the xml file is read and the beans are instantiated(created)?

Thank you

Upvotes: 10

Views: 2749

Answers (2)

Shailendra
Shailendra

Reputation: 9102

Although you should not be worried much about the internal structures if you are just beginning to learn Spring but for the sake of knowledge in almost all cases the underlying class is DefaultSingletonBeanRegistry and as you can see by going through the source code here it maintains a ConcurrentHashMap of singleton objects. Also there are similar other map object for other information being stored.

private final Map<String, Object> singletonObjects = new ConcurrentHashMap<String, Object>(64);

Upvotes: 14

Yasin
Yasin

Reputation: 2029

You can think of it as a Map where the keys are bean ids and the values are actual Objects.

Upvotes: 0

Related Questions