SlideShare a Scribd company logo
1. Spring intro IoC
Spring Framework
• Spring is a lightweight framework. It can be thought of
as a framework of frameworks because it provides
support to various frameworks such as Struts,
Hibernate, Tapestry, EJB, JSF etc. The framework, in
broader sense, can be defined as a structure where we
find solution of the various technical problems.
• The Spring framework comprises several modules such
as IOC, AOP, DAO, Context, ORM, WEB MVC etc. We
will learn these modules in next page. Let's understand
the IOC and Dependency Injection first.
Inversion Of Control (IOC) and
Dependency Injection
• These are the design patterns that are used to remove
dependency from the programming code. They make
the code easier to test and maintain. Let's understand
this with the following code:
class Employee{
Address address;
Employee(){
address=new Address();
}
}
• In such case, there is dependency between the
Employee and Address (tight coupling).
• In the Inversion of Control scenario, we do this something like this:
class Employee{
Address address;
Employee(Address address){
this.address=address;
}
}
• Thus, IOC makes the code loosely coupled. In such case, there is no
need to modify the code if our logic is moved to new environment.
• In Spring framework, IOC container is responsible to inject the
dependency. We provide metadata to the IOC container either by
XML file or annotation.
• Advantage of Dependency Injection
– makes the code loosely coupled so easy to maintain
– makes the code easy to test
Advantages of Spring Framework
• 1) Predefined Templates
– Spring framework provides templates for JDBC, Hibernate, JPA etc.
technologies. So there is no need to write too much code. It hides the
basic steps of these technologies.
• Let's take the example of JdbcTemplate, you don't need to write the code
for exception handling, creating connection, creating statement,
committing transaction, closing connection etc. You need to write the
code of executing query only. Thus, it save a lot of JDBC code.
• 2) Loose Coupling
– The Spring applications are loosely coupled because of dependency
injection.
• 3) Easy to test
– The Dependency Injection makes easier to test the application. The
EJB or Struts application require server to run the application but
Spring framework doesn't require server.
• 4) Lightweight
– Spring framework is lightweight because of its POJO
implementation. The Spring Framework doesn't force the
programmer to inherit any class or implement any
interface. That is why it is said non-invasive.
• 5) Fast Development
– The Dependency Injection feature of Spring Framework
and it support to various frameworks makes the easy
development of JavaEE application.
• 6) Powerful abstraction
– It provides powerful abstraction to JavaEE specifications
such as JMS, JDBC, JPA and JTA.
• 7) Declarative support
– It provides declarative support for caching, validation,
transactions and formatting.
Spring Modules
• The Spring Framework consists of features
organized into about 20 modules. These
modules are grouped into Core Container,
Data Access/Integration, Web, AOP (Aspect
Oriented Programming), Instrumentation, and
Test, as shown in the following diagram.
1. Spring intro IoC
• Test
– This layer provides support of testing with JUnit and
TestNG.
• Spring Core Container
– The Spring Core container contains core, beans, context
and expression language (EL) modules.
– Core and Beans
• These modules provide IOC and Dependency Injection features.
– Context
• This module supports internationalization (I18N), EJB, JMS, Basic
Remoting.
– Expression Language
• It is an extension to the EL defined in JSP. It provides support to
setting and getting property values, method invocation, accessing
collections and indexers, named variables, logical and arithmetic
operators, retrieval of objects by name etc.
• AOP, Aspects and Instrumentation
– These modules support aspect oriented programming
implementation where you can use Advices, Pointcuts etc. to
decouple the code.
– The aspects module provides support to integration with
AspectJ.
– The instrumentation module provides support to class
instrumentation and classloader implementations.
• Data Access / Integration
– This group comprises of JDBC, ORM, OXM, JMS and Transaction
modules. These modules basically provide support to interact
with the database.
• Web
– This group comprises of Web, Web-Servlet, Web-Struts and
Web-Portlet. These modules provide support to create web
application.
IoC Container
• The IoC container is responsible to instantiate,
configure and assemble the objects. The IoC
container gets informations from the XML file and
works accordingly. The main tasks performed by
IoC container are:
– to instantiate the application class
– to configure the object
– to assemble the dependencies between the objects
• There are two types of IoC containers. They are:
– BeanFactory
– ApplicationContext
Difference between BeanFactory and
the ApplicationContext
• The org.springframework.beans.factory.
BeanFactory and the org.springframework.context.
ApplicationContext interfaces acts as the IoC container.
The ApplicationContext interface is built on top of the
BeanFactory interface. It adds some extra functionality
than BeanFactory such as simple integration with
Spring's AOP, message resource handling (for I18N),
event propagation, application layer specific context
(e.g. WebApplicationContext) for web application. So it
is better to use ApplicationContext than BeanFactory.

More Related Content

What's hot (20)

PDF
Spring Framework - Core
Dzmitry Naskou
 
PPTX
JSF 2.3: Integration with Front-End Frameworks
Ian Hlavats
 
PPT
Webapplication ppt prepared by krishna ballabh gupta
Shivalik college of engineering
 
PPTX
Devjyotippt
Gaurav pathak
 
PDF
[2015/2016] Backbone JS
Ivano Malavolta
 
ODP
Spring User Guide
Muthuselvam RS
 
PPTX
Best Practices for JSF, Gameduell 2013
Edward Burns
 
PDF
JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PDF
Spring mvc
Hamid Ghorbani
 
PDF
Spring MVC Framework
Hùng Nguyễn Huy
 
PPTX
Web apps architecture
Tanmoy Barman
 
PDF
Introduction to Spring Framework
Hùng Nguyễn Huy
 
PDF
Getting Started with Spring Framework
Edureka!
 
PDF
[2015/2016] Require JS and Handlebars JS
Ivano Malavolta
 
PPT
Concepts of Asp.Net
vidyamittal
 
PPT
Spring Framework
nomykk
 
PPS
Jdbc architecture and driver types ppt
kamal kotecha
 
PPSX
Spring - Part 1 - IoC, Di and Beans
Hitesh-Java
 
PPTX
Spring mvc
Harshit Choudhary
 
PPTX
Java Training in Chennai
raj esaki
 
Spring Framework - Core
Dzmitry Naskou
 
JSF 2.3: Integration with Front-End Frameworks
Ian Hlavats
 
Webapplication ppt prepared by krishna ballabh gupta
Shivalik college of engineering
 
Devjyotippt
Gaurav pathak
 
[2015/2016] Backbone JS
Ivano Malavolta
 
Spring User Guide
Muthuselvam RS
 
Best Practices for JSF, Gameduell 2013
Edward Burns
 
JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Spring mvc
Hamid Ghorbani
 
Spring MVC Framework
Hùng Nguyễn Huy
 
Web apps architecture
Tanmoy Barman
 
Introduction to Spring Framework
Hùng Nguyễn Huy
 
Getting Started with Spring Framework
Edureka!
 
[2015/2016] Require JS and Handlebars JS
Ivano Malavolta
 
Concepts of Asp.Net
vidyamittal
 
Spring Framework
nomykk
 
Jdbc architecture and driver types ppt
kamal kotecha
 
Spring - Part 1 - IoC, Di and Beans
Hitesh-Java
 
Spring mvc
Harshit Choudhary
 
Java Training in Chennai
raj esaki
 

Similar to 1. Spring intro IoC (20)

PPTX
unit_1_spring_1.pptxfgfgggjffgggddddgggg
zmulani8
 
PPT
Spring ppt
Mumbai Academisc
 
ODT
Spring framework
Shivi Kashyap
 
PDF
Spring Framework Tutorial | VirtualNuggets
Virtual Nuggets
 
PPTX
Introduction to Spring
Sujit Kumar
 
PPTX
spring
Suman Behara
 
PPTX
Spring
Suman Behara
 
PPT
Spring - a framework written by developers
MarcioSoaresPereira1
 
PPTX
Spring
komalpreethi
 
DOCX
Month 3 report
PRIYANKA FNU
 
PPTX
Introduction to Spring & Spring BootFramework
Kongu Engineering College, Perundurai, Erode
 
PDF
Framework adoption for java enterprise application development
Clarence Ho
 
PPT
Hybernat and structs, spring classes in mumbai
Vibrant Technologies & Computers
 
PDF
스프링 프레임워크
Yoonki Chang
 
PPTX
Introduction to j2 ee frameworks
Mukesh Kumar
 
PPTX
Spring framework
Kani Selvam
 
DOCX
Spring notes
Rajeev Uppala
 
PPTX
Java Spring
AathikaJava
 
DOC
The Complete Spring Tutorial
cribes
 
unit_1_spring_1.pptxfgfgggjffgggddddgggg
zmulani8
 
Spring ppt
Mumbai Academisc
 
Spring framework
Shivi Kashyap
 
Spring Framework Tutorial | VirtualNuggets
Virtual Nuggets
 
Introduction to Spring
Sujit Kumar
 
spring
Suman Behara
 
Spring
Suman Behara
 
Spring - a framework written by developers
MarcioSoaresPereira1
 
Spring
komalpreethi
 
Month 3 report
PRIYANKA FNU
 
Introduction to Spring & Spring BootFramework
Kongu Engineering College, Perundurai, Erode
 
Framework adoption for java enterprise application development
Clarence Ho
 
Hybernat and structs, spring classes in mumbai
Vibrant Technologies & Computers
 
스프링 프레임워크
Yoonki Chang
 
Introduction to j2 ee frameworks
Mukesh Kumar
 
Spring framework
Kani Selvam
 
Spring notes
Rajeev Uppala
 
Java Spring
AathikaJava
 
The Complete Spring Tutorial
cribes
 
Ad

Recently uploaded (20)

PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Ad

1. Spring intro IoC

  • 2. Spring Framework • Spring is a lightweight framework. It can be thought of as a framework of frameworks because it provides support to various frameworks such as Struts, Hibernate, Tapestry, EJB, JSF etc. The framework, in broader sense, can be defined as a structure where we find solution of the various technical problems. • The Spring framework comprises several modules such as IOC, AOP, DAO, Context, ORM, WEB MVC etc. We will learn these modules in next page. Let's understand the IOC and Dependency Injection first.
  • 3. Inversion Of Control (IOC) and Dependency Injection • These are the design patterns that are used to remove dependency from the programming code. They make the code easier to test and maintain. Let's understand this with the following code: class Employee{ Address address; Employee(){ address=new Address(); } } • In such case, there is dependency between the Employee and Address (tight coupling).
  • 4. • In the Inversion of Control scenario, we do this something like this: class Employee{ Address address; Employee(Address address){ this.address=address; } } • Thus, IOC makes the code loosely coupled. In such case, there is no need to modify the code if our logic is moved to new environment. • In Spring framework, IOC container is responsible to inject the dependency. We provide metadata to the IOC container either by XML file or annotation. • Advantage of Dependency Injection – makes the code loosely coupled so easy to maintain – makes the code easy to test
  • 5. Advantages of Spring Framework • 1) Predefined Templates – Spring framework provides templates for JDBC, Hibernate, JPA etc. technologies. So there is no need to write too much code. It hides the basic steps of these technologies. • Let's take the example of JdbcTemplate, you don't need to write the code for exception handling, creating connection, creating statement, committing transaction, closing connection etc. You need to write the code of executing query only. Thus, it save a lot of JDBC code. • 2) Loose Coupling – The Spring applications are loosely coupled because of dependency injection. • 3) Easy to test – The Dependency Injection makes easier to test the application. The EJB or Struts application require server to run the application but Spring framework doesn't require server.
  • 6. • 4) Lightweight – Spring framework is lightweight because of its POJO implementation. The Spring Framework doesn't force the programmer to inherit any class or implement any interface. That is why it is said non-invasive. • 5) Fast Development – The Dependency Injection feature of Spring Framework and it support to various frameworks makes the easy development of JavaEE application. • 6) Powerful abstraction – It provides powerful abstraction to JavaEE specifications such as JMS, JDBC, JPA and JTA. • 7) Declarative support – It provides declarative support for caching, validation, transactions and formatting.
  • 7. Spring Modules • The Spring Framework consists of features organized into about 20 modules. These modules are grouped into Core Container, Data Access/Integration, Web, AOP (Aspect Oriented Programming), Instrumentation, and Test, as shown in the following diagram.
  • 9. • Test – This layer provides support of testing with JUnit and TestNG. • Spring Core Container – The Spring Core container contains core, beans, context and expression language (EL) modules. – Core and Beans • These modules provide IOC and Dependency Injection features. – Context • This module supports internationalization (I18N), EJB, JMS, Basic Remoting. – Expression Language • It is an extension to the EL defined in JSP. It provides support to setting and getting property values, method invocation, accessing collections and indexers, named variables, logical and arithmetic operators, retrieval of objects by name etc.
  • 10. • AOP, Aspects and Instrumentation – These modules support aspect oriented programming implementation where you can use Advices, Pointcuts etc. to decouple the code. – The aspects module provides support to integration with AspectJ. – The instrumentation module provides support to class instrumentation and classloader implementations. • Data Access / Integration – This group comprises of JDBC, ORM, OXM, JMS and Transaction modules. These modules basically provide support to interact with the database. • Web – This group comprises of Web, Web-Servlet, Web-Struts and Web-Portlet. These modules provide support to create web application.
  • 11. IoC Container • The IoC container is responsible to instantiate, configure and assemble the objects. The IoC container gets informations from the XML file and works accordingly. The main tasks performed by IoC container are: – to instantiate the application class – to configure the object – to assemble the dependencies between the objects • There are two types of IoC containers. They are: – BeanFactory – ApplicationContext
  • 12. Difference between BeanFactory and the ApplicationContext • The org.springframework.beans.factory. BeanFactory and the org.springframework.context. ApplicationContext interfaces acts as the IoC container. The ApplicationContext interface is built on top of the BeanFactory interface. It adds some extra functionality than BeanFactory such as simple integration with Spring's AOP, message resource handling (for I18N), event propagation, application layer specific context (e.g. WebApplicationContext) for web application. So it is better to use ApplicationContext than BeanFactory.