Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 490
Ciprian Constantin Hurmuzache Avatar asked Aug 29 '14 09:08

Ciprian Constantin Hurmuzache


1 Answers

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);
like image 109
Shailendra Avatar answered Oct 10 '22 18:10

Shailendra