• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer
  • Core Java
  • Design Patterns
  • JSP
  • Servlets
  • Building Tools
  • jQuery
  • Spring
  • Hibernate
  • Mongo DB
  • More
    • HTML
    • SCJP
    • AJAX
    • UML
    • Struts
    • J2EE
    • Testing
    • Angular JS

J2EE Reference

  • Home
  • About Us
    • Java Learning Centers
  • Contact Us

Spring Bean Factory

July 16, 2012 By j2eereference Leave a Comment

Spring Bean Factory

In this article we will see how Spring Bean factory works. For understanding the concept lets first  understand what is a spring container  .

What is spring container?

We know that what is a servlet container,Tomcat is a servlet container. Tomcat creates servlet object which are required in order to run the application you will configure all the servlets in a configuration file and , tomcat reads the XML and identify the servlets to be instantiated and it creates those servlets.

Spring does something similar to this . But not the servlets ,It is a container of beans. So u can have as many objects you want inside the container All these objects are managed by the spring container . Spring container handles instantiating, managing the life cycle of the object, it handles the destruction of the objects.

You  can also have objects  outside of the container , But adding objects outside the container are not taken care by the container.

In the above figure ObjectA, ObjectB and ObjectC are inside the spring container and ObjectD and ObjectE are outside the container. So if you want to instantiate ObjectD and ObjectE , we need to do new ObjectD() and new ObjectE() respectively.

Spring container will take care of instatiating ObjectA,B and C

Spring Bean Factory

We know that the use of factory pattern, Factory class provide the Object of required class.

lets see the architecture in the below figure

Here when classA required an ObejctB , We will make a call to Object Factory to get the corresponding object. Factory class will take care of instantiating the required class and return the object.

How does Spring been factory provide the bean object?

Spring container reads the configuration file which defines all the objects , this configuration is the blueprint of the beans which are defined in the factory.

When spring container gets request for any bean object defined in spring XML , container will instantiate and provide the object .

Related Posts

  • Spring JSR-250 Annotations
  • Injecting singleton class with spring
  • Writing First Aspect in spring
  • What is Aspect Oriented Programming (AOP)
  • Autowired Annotation
  • Constructor injection in spring
  • Bean autowiring
  • LifeCycle call backs in Spring
  • BeanPostProcessor in Spring
  • Initializing list of values using Spring

Filed Under: Spring

Reader Interactions

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

FOLLOW US ONLINE

  • View J2eereference-166104970118637’s profile on Facebook
  • View j2eereference’s profile on Twitter
  • View j2eereference’s profile on LinkedIn

Subscribe by email

Recent posts

  • Java Buzzwords
  • Anonymous Inner Class in Java
  • Network Programming – java.net Package
  • Java Regular Expressions
  • Method Local Inner Class in Java
  • URL Processing in Java
  • Iterator Design Pattern Implementation using Java
  • Strategy Design Pattern Implementation using Java
  • Decorator Design Pattern
  • Adapter Design Pattern Implementation using Java
  • JSF Composite Components
  • JSF UI Components
  • What is JavaServer Faces (JSF)?
  • GOF Design Patterns
  • History and Need for Design Patterns

Footer

Core Java
Design Patterns
JSP
Servlets
HTML
Building Tools
AJAX
SCJP
jQuery
Testing
Spring
UML
Struts
Java Centers
Java Training
Home
About Us
Contact Us
Copyright © j2eereference.com. All right reserved.