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

PPTX
Angular jS Introduction by Google
 
PPTX
Introduction to Spring Framework
 
PDF
Spring framework
ODP
Java Web Programming [1/9] : Introduction to Web Application
PPTX
Introduction to Ibatis by Rohit
PPTX
Spring Framework
PPTX
Java ee introduction
PPTX
Spring Framework Rohit
Angular jS Introduction by Google
 
Introduction to Spring Framework
 
Spring framework
Java Web Programming [1/9] : Introduction to Web Application
Introduction to Ibatis by Rohit
Spring Framework
Java ee introduction
Spring Framework Rohit

What's hot (20)

PDF
Spring Framework - Core
PPTX
JSF 2.3: Integration with Front-End Frameworks
PPT
Webapplication ppt prepared by krishna ballabh gupta
PPTX
Devjyotippt
PDF
[2015/2016] Backbone JS
ODP
Spring User Guide
PPTX
Best Practices for JSF, Gameduell 2013
PDF
JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...
PDF
Spring mvc
PDF
Spring MVC Framework
PPTX
Web apps architecture
PDF
Introduction to Spring Framework
PDF
Getting Started with Spring Framework
PDF
[2015/2016] Require JS and Handlebars JS
PPT
Concepts of Asp.Net
PPT
Spring Framework
PPS
Jdbc architecture and driver types ppt
PPSX
Spring - Part 1 - IoC, Di and Beans
PPTX
Spring mvc
PPTX
Java Training in Chennai
Spring Framework - Core
JSF 2.3: Integration with Front-End Frameworks
Webapplication ppt prepared by krishna ballabh gupta
Devjyotippt
[2015/2016] Backbone JS
Spring User Guide
Best Practices for JSF, Gameduell 2013
JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...
Spring mvc
Spring MVC Framework
Web apps architecture
Introduction to Spring Framework
Getting Started with Spring Framework
[2015/2016] Require JS and Handlebars JS
Concepts of Asp.Net
Spring Framework
Jdbc architecture and driver types ppt
Spring - Part 1 - IoC, Di and Beans
Spring mvc
Java Training in Chennai
Ad

Similar to 1. Spring intro IoC (20)

PPTX
unit_1_spring_1.pptxfgfgggjffgggddddgggg
PPT
Spring ppt
ODT
Spring framework
PDF
Spring Framework Tutorial | VirtualNuggets
PPTX
Introduction to Spring
PPTX
spring
PPTX
Spring
PPT
Spring - a framework written by developers
PPTX
Spring
DOCX
Month 3 report
PPTX
Introduction to Spring & Spring BootFramework
PDF
Framework adoption for java enterprise application development
PPT
Hybernat and structs, spring classes in mumbai
PDF
스프링 프레임워크
PPTX
Introduction to j2 ee frameworks
PPTX
Spring framework
DOCX
Spring notes
PPTX
Java Spring
DOC
The Complete Spring Tutorial
unit_1_spring_1.pptxfgfgggjffgggddddgggg
Spring ppt
Spring framework
Spring Framework Tutorial | VirtualNuggets
Introduction to Spring
spring
Spring
Spring - a framework written by developers
Spring
Month 3 report
Introduction to Spring & Spring BootFramework
Framework adoption for java enterprise application development
Hybernat and structs, spring classes in mumbai
스프링 프레임워크
Introduction to j2 ee frameworks
Spring framework
Spring notes
Java Spring
The Complete Spring Tutorial
Ad

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
Spectroscopy.pptx food analysis technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation theory and applications.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Cloud computing and distributed systems.
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
A Presentation on Artificial Intelligence
PDF
Empathic Computing: Creating Shared Understanding
PDF
Spectral efficient network and resource selection model in 5G networks
Programs and apps: productivity, graphics, security and other tools
sap open course for s4hana steps from ECC to s4
Unlocking AI with Model Context Protocol (MCP)
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
A comparative analysis of optical character recognition models for extracting...
Spectroscopy.pptx food analysis technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
cuic standard and advanced reporting.pdf
Encapsulation theory and applications.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Cloud computing and distributed systems.
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Per capita expenditure prediction using model stacking based on satellite ima...
A Presentation on Artificial Intelligence
Empathic Computing: Creating Shared Understanding
Spectral efficient network and resource selection model in 5G networks

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.