ApplicationContext interface extends the BeanFactory interface.
A big difference between an application context and a bean factory is how
singleton beans are loaded. A bean factory lazily loads all beans, deferring bean
creation until the getBean() method is called. An application context is a bit
smarter and preloads all singleton beans upon context startup. By preloading
singleton beans, you ensure that they will be ready to use when needed—your
application won’t have to wait for them to be created.
4 comments:
What is the benefit of loading singelton beans at the startup ?
If there are more singelton beans then normal beans then? more memeory will be consumed at starting
so why singelton beans are loaded at the start up in applicationcontext
What is the benefit of loading singelton beans at the startup ?
If there are more singelton beans then normal beans then? more memeory will be consumed at starting
so why singelton beans are loaded at the start up in applicationcontext
What is the benefit of loading singelton beans at the startup ?
If there are more singelton beans then normal beans then? more memeory will be consumed at starting
so why singelton beans are loaded at the start up in applicationcontext?
@shaswat, if you have all the singleton beans preloaded, you application will be much faster, as while Autowiring dependency you wouldn't have to wait for the bean initialization. This is the reason while using spring in web applications we use ContextLoaderListener which delegates the calls to applicationContext which loads all the beans.
Post a Comment