Loading the bean which is configured in the Spring-context.xml file, can be done in two ways :

1. Eager loading or Aggressive loading
2. Lazy Loading
Eager loading or Aggressive loading 
In the case of Aggressive loading all the beans will be loaded and initialized at container start-up. It is called as eager or aggressive loading because of loading all the bean , instance instantiated and initializing at the container start-up only. We just have to write some configuration in the XML file to indicate container for eager loading. This loading is at the bean level . 

To load any bean aggressively we have to mention lazy-init="false" . 
Note that this configuration is at the bean level that means if we want to load all the configured bean to load eagerly then have to mention in each bean tag. If not mention then also by default it load eagerly.  

Lazy loading 
In the case of lazy loading all the beans will be loaded, instantiated and initialized when the container try to use them by calling getBeans() method. We just have to mention lazy-init="true" in order to load the beans lazily. 
So bean will be loaded according to the configured lazy-init attribute with its corresponding value , or if not mentioned then by default it load Eagerly.  

Note : All bean having singleton scope will follow aggressive loading and all bean with prototype scope will follow lazy loading.

To know more about bean scopes - Click Here

Related Posts:

  • Spring Implicit Wiring : byType In this type of auto-wiring container detect the bean instance with its data type and checks the data type of the bean instance running in the container with the bean type mentioned in the dependency bean. Some of the task … Read More
  • Spring Framework Architecture Spring framework is a layered architecture where Spring 2.x is divided into 6 modules. So here i am going to explain all 6 modules one by one. Spring Core Module: It provide the fundamental part of spring Framework lik… Read More
  • Alternatives of Open Session In View(OSIV) Today I am going to tell you other alternative you can do in order to avoid LazyInitializationException: Session has been closed. If you are using SPRING with HIBERNATE that you can take the advantages of IOC and AOP. These … Read More
  • Benefit of using Spring Framework Provide a good programming practice by decoupling the layers. If you are using spring in your project it decouples the layers and hence it's easy to write the test case for them. So it's easy from maintenance point of view.… Read More
  • IoC Container In Spring IOC stands for the Inversion of Container. It is a container used in Spring core Framework. It is responsible for managing the states of the object i.e from its creation till its destruction. Before Spring framework, develo… Read More

22 comments:

  1. That’s an amazing post. I’m sure these techniques will work for beginners. thanks for sharing great admin



    NITRO PDF PRO 11

    ReplyDelete


  2. Thanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog. It is very nicely explained. Your article adds best knowledge to our Java EE Training in Chennai. or learn thru Java EE Training in Chennai Students.

    ReplyDelete
  3. If you're a makeup artists, singers, actors, stylist, anchors, gym trainer, voice over artists jobs in India. singing jobs

    ReplyDelete
  4. Shop for the best gift items at your spending limit. Enjoy your day with the best gift store around. unique christmas gifts

    ReplyDelete
  5. Get instant news about all viral news, upcoming web series, youtube videos, memes etc. trending news in india

    ReplyDelete
  6. Searching for this easy and simple digital marketing meaning in hindi and know
    digital marketing kya hota hai. best convection microwave oven under 10000

    ReplyDelete
  7. Get the best good morning quotes, hindi thoughts, Stories, suvichar & thoughts in hindi, shayari.Grab the best good morning, inspirational, motivational, moral stories and success, attitude, love, good morning, life, funny, sad. motivational quotes hindi

    ReplyDelete

Blog Archive

Ads 468x60px

.

Ads

.

Featured Posts

Popular Posts

Like Us On FaceBook

Total Pageviews

201978

Online Members

Live Traffic