Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

Session 11

SPRING INTRO
Spring Intro

• Inversion of Control (IoC) & IoC Container


• IoC solves the problem of:
– Object instantiation
– Inter-object dependencies
– Object destruction
 object lifecycle + dependencies
• IoC  “Don’t call me, I will call you”

• These objects are beans


• Simply put, beans are managed objects which a so-called bean container
can control: instantiate, setting members, destroy, etc
• In order to be manage-able, the bean classes need to simply have getters
and setters for all the properties we want to manage
• Also, all classes used by the beans must also be beans in order for the
container to be able to manage them
Instantiate the Spring IoC

• You have to instantiate the Spring IoC container for it to create bean
instances
• Two types of IoC containers:
– Bean factory: the most basic one
– Application Context: a more advanced, used in web applications
• Bean definitions are all placed in an XML file (for instance), and we can call
than file beans.xml
Spring Intro
Beans

• The objects that form the backbone of your


application and that are managed by the Spring
IoC container are called beans.
• A bean is an object that is instantiated,
assembled, and otherwise managed by a Spring
IoC container.
• These beans are created with the configuration
metadata that you supply to the container, for
example, in the form of XML <bean/> definitions
which you have already seen in previous
chapters.
Beans
Spring Configuration

• XML Configuration
Java and Annotation Configuration
Bibliography

• http://www.tutorialspoint.com/jsp/
index.htm
• http://docs.spring.io/spring/docs/cur
rent/spring-framework-reference/ht
ml/
overview.html
• http://www.tutorialspoint.com/spring
/
spring_overview.htm
• http://www.mkyong.com/spring3/spr

You might also like