SlideShare a Scribd company logo
Spring Framework
Spring Overview
• Spring is an open source layered Java/J2EE application
framework
• Created by Rod Johnson
• Based on book “Expert one-on-one J2EE Design and
Development” (October, 2002)
• Current version 2.0.6 (released on 2007-06-18)
• The Spring Framework is licensed under the terms of the
Apache License, Version 2.0 and can be downloaded at:
• http://www.springframework.org/download
• Philosophy: J2EE should be easier to use,
“Lightweight Container” concept
A software framework is a re-usable
design for a software system.
What are Lightweight Frameworks?
• Non-intrusive
• No container requirements
• Simplify application development
• Remove re-occurring pattern code
• Productivity friendly
• Unit test friendly
• Very pluggable
• Usually open source
• Examples:
• Spring, Pico, Hivemind
• Hibernate, IBatis, Castor
• WebWork
• Quartz
• Sitemesh
Spring Mission Statement
• J2EE should be easier to use
• It's best to program to interfaces, rather than classes. Spring reduces
the complexity cost of using interfaces to zero.
• JavaBeans offer a great way of configuring applications
• OO design is more important than any implementation technology,
such as J2EE
• Checked exceptions are overused in Java. A framework shouldn't
force you to catch exceptions you're unlikely to be able to recover
from.
• Testability is essential, and a framework such as Spring should help
make your code easier to test
• Spring should be a pleasure to use
• Your application code should not depend on Spring APIs
• Spring should not compete with good existing solutions, but should
foster integration. (For example, JDO and Hibernate are great O/R
mapping solutions. Don't need to develop another one).
Modules of the Spring Framework
The Spring Framework can be considered as a collection
of frameworks-in-the-framework:
• Core - Inversion of Control (IoC) and Dependency Injection
• AOP - Aspect-oriented programming
• DAO - Data Access Object support, transaction management,
JDBC-abstraction
• ORM - Object Relational Mapping data access, integration
layers for JPA, JDO, Hibernate, and iBatis
• MVC - Model-View-Controller implementation for web-
applications
• Remote Access, Authentication and Authorization, Remote
Management, Messaging Framework, Web Services, Email,
Testing, …
Overview of the Spring Framework
Very loosely coupled, components widely reusable and
separately packaged.
Spring Details
• Spring allows to decouple software layers by injecting a component’s
dependencies at runtime rather than having them declared at compile time via
importing and instantiating classes.
• Spring provides integration for J2EE services such as EJB, JDBC, JNDI,
JMS, JTA. It also integrates several popular ORM toolkits such as Hibernate
and JDO and assorted other services as well.
• One of the highly touted features is declarative transactions, which allows the
developer to write transaction-unaware code and configure transactions in
Spring config files.
• Spring is built on the principle of unchecked exception handling. This also
reduces code dependencies between layers. Spring provides a granular
exception hierarchy for data access operations and maps JDBC, EJB, and
ORM exceptions to Spring exceptions so that applications can get better
information about the error condition.
• With highly decoupled software layers and programming to interfaces, each
layer is easier to test. Mock objects is a testing pattern that is very useful in
this regard.
Advantages of Spring Architecture
• Enable you to write powerful, scalable applications using POJOs
• Lifecycle – responsible for managing all your application
components, particularly those in the middle tier container sees
components through well-defined lifecycle: init(), destroy()
• Dependencies - Spring handles injecting dependent components
without a component knowing where they came from (IoC)
• Configuration information - Spring provides one consistent way of
configuring everything, separate configuration from application
logic, varying configuration
• In J2EE (e.g. EJB) it is easy to become dependent on container and
deployment environment, proliferation of pointless classes
(locators/delegates); Spring eliminates them
• Cross-cutting behavior (resource management is cross-cutting
concern, easy to copy-and-paste everywhere)
• Portable (can use server-side in web/ejb app, client-side in swing app,
business logic is completely portable)
Spring Solutions
• Solutions address major J2EE problem areas:
• Web application development (MVC)
• Enterprise Java Beans (EJB, JNDI)
• Database access (JDBC, iBatis, ORM)
• Transaction management (JTA, Hibernate, JDBC)
• Remote access (Web Services, RMI)
• Each solution builds on the core architecture
• Solutions foster integration, they do not re-invent
the wheel
How to Start Using Spring
• Download Spring from www.springframework.org, e.g.
spring-framework-2.0.6-with-dependencies.zip
• Unzip to some location, e.g.
C:toolsspring-framework-2.0.6
• Folder C:toolsspring-framework-2.0.6dist
contains Spring distribution jar files
• Add libraries to your application classpath
and start programming with Spring
Inversion of Control (IoC)
• Central in the Spring is its Inversion of Control container
• Based on “Inversion of Control Containers and the
Dependency Injection pattern” (Martin Fowler)
• Provides centralized, automated configuration, managing and
wiring of application Java objects
• Container responsibilities:
• creating objects,
• configuring objects,
• calling initialization methods
• passing objects to registered callback objects
• etc
• All together form the object lifecycle which is one of the most
important features
Java objects that are managed
by the Spring IoC container are
referred to as beans
Dependency Injection – Non-IoC
public class MainBookmarkProcessor implements BookmarkProcessor{
private PageDownloader pageDownloader;
private RssParser rssParser;
public List<Bookmark> loadBookmarks()
{
// direct initialization
pageDownloader = new ApachePageDownloader();
rssParser = new JenaRssParser();
// or factory initialization
// pageDownloader = PageDownloaderFactory.getPageDownloader();
// rssParser = RssParserFactory.getRssParser();
// use initialized objects
pageDownloader.downloadPage(url);
rssParser.extractBookmarks(fileName, resourceName);
// ...
}
Dependency Injection - IoC
• Beans define their dependencies through constructor arguments or
properties
• Container resolves (injects) dependencies of components by setting
implementation object during runtime
• BeanFactory interface - the core that
loads bean definitions and manages beans
• Most commonly used implementation
is the XmlBeanFactory class
• Allows to express the objects that compose
application, and the interdependencies
between such objects, in terms of XML
• The XmlBeanFactory takes this XML
configuration metadata and uses it to create a fully configured system
Non-IoC versus IoC
Non Inversion of Control
approach
Inversion of Control
approach
IoC Basics
• Basic JavaBean pattern:
• include a “getter” and “setter” method for each field:
• Rather than locating needed resources, application components
provide setters through which resources are passed in during
initialization
• In Spring Framework, this pattern is used extensively, and
initialization is usually done through configuration file rather than
application code
class MyBean {
private int counter;
public int getCounter()
{ return counter; }
public void setCounter(int counter)
{ this.counter = counter; }
}
IoC Java Bean
public class MainBookmarkProcessor implements BookmarkProcessor{
private PageDownloader pageDownloader;
private RssParser rssParser;
public List<Bookmark> loadBookmarks()
{
pageDownloader.downloadPage(url);
rssParser.extractBookmarks(fileName, resourceName);
// ...
}
public void setPageDownloader(PageDownloader pageDownloader){
this.pageDownloader = pageDownloader;
}
public void setRssParser(RssParser rssParser){
this.rssParser = rssParser;
}
References
• Spring Home:
http://www.springframework.org
• Inversion of Control Containers and the Dependency
Injection pattern
http://www.martinfowler.com/articles/injection.html
• Spring IoC Container:
http://static.springframework.org/spring/docs/2.0.x/referenc
e/beans.html
• Introduction to the Spring Framework by Rod Johnson
http://www.theserverside.com/tt/articles/article.tss?
l=SpringFramework
Ad

More Related Content

What's hot (20)

Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Serhat Can
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
Dzmitry Naskou
 
Spring ppt
Spring pptSpring ppt
Spring ppt
Mumbai Academisc
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
Alex Movila
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
tola99
 
Spring AOP in Nutshell
Spring AOP in Nutshell Spring AOP in Nutshell
Spring AOP in Nutshell
Onkar Deshpande
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
nomykk
 
Java spring framework
Java spring frameworkJava spring framework
Java spring framework
Rajiv Gupta
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
NexThoughts Technologies
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
Pravin Pundge
 
Spring Framework - Data Access
Spring Framework - Data AccessSpring Framework - Data Access
Spring Framework - Data Access
Dzmitry Naskou
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBoot
Josué Neis
 
Spring boot
Spring bootSpring boot
Spring boot
Gyanendra Yadav
 
Spring boot
Spring bootSpring boot
Spring boot
Pradeep Shanmugam
 
Spring framework aop
Spring framework aopSpring framework aop
Spring framework aop
Taemon Piya-Lumyong
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
Naphachara Rattanawilai
 
Reactjs Basics
Reactjs BasicsReactjs Basics
Reactjs Basics
Hamid Ghorbani
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jiayun Zhou
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
07.pallav
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
Jonathan Holloway
 

Viewers also liked (7)

Spring Framework Rohit
Spring Framework RohitSpring Framework Rohit
Spring Framework Rohit
Rohit Prabhakar
 
Spring
SpringSpring
Spring
Prashant Kumar
 
Getting Started with Spring Framework
Getting Started with Spring FrameworkGetting Started with Spring Framework
Getting Started with Spring Framework
Edureka!
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
zeeshanhanif
 
SpringPeople Introduction to Spring Framework
SpringPeople Introduction to Spring FrameworkSpringPeople Introduction to Spring Framework
SpringPeople Introduction to Spring Framework
SpringPeople
 
Spring MVC Basics
Spring MVC BasicsSpring MVC Basics
Spring MVC Basics
Bozhidar Bozhanov
 
Ppt springs
Ppt springsPpt springs
Ppt springs
Krishna Kumar Pankaj
 
Ad

Similar to Spring introduction (20)

Spring intro classes-in-mumbai
Spring intro classes-in-mumbaiSpring intro classes-in-mumbai
Spring intro classes-in-mumbai
vibrantuser
 
Hybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbaiHybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbai
Vibrant Technologies & Computers
 
Spring framework
Spring frameworkSpring framework
Spring framework
Kani Selvam
 
Spring
SpringSpring
Spring
Suman Behara
 
Java Spring
Java SpringJava Spring
Java Spring
AathikaJava
 
Spring - a framework written by developers
Spring - a framework written by developersSpring - a framework written by developers
Spring - a framework written by developers
MarcioSoaresPereira1
 
스프링 프레임워크
스프링 프레임워크스프링 프레임워크
스프링 프레임워크
Yoonki Chang
 
Introduction to Spring & Spring BootFramework
Introduction to Spring  & Spring BootFrameworkIntroduction to Spring  & Spring BootFramework
Introduction to Spring & Spring BootFramework
Kongu Engineering College, Perundurai, Erode
 
unit_1_spring_1.pptxfgfgggjffgggddddgggg
unit_1_spring_1.pptxfgfgggjffgggddddggggunit_1_spring_1.pptxfgfgggjffgggddddgggg
unit_1_spring_1.pptxfgfgggjffgggddddgggg
zmulani8
 
spring
springspring
spring
Suman Behara
 
Introduction to Spring
Introduction to SpringIntroduction to Spring
Introduction to Spring
Sujit Kumar
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
Mukesh Kumar
 
Spring framework
Spring frameworkSpring framework
Spring framework
Shivi Kashyap
 
Framework adoption for java enterprise application development
Framework adoption for java enterprise application developmentFramework adoption for java enterprise application development
Framework adoption for java enterprise application development
Clarence Ho
 
Oracle Data Integrator
Oracle Data Integrator Oracle Data Integrator
Oracle Data Integrator
IT Help Desk Inc
 
Spring notes
Spring notesSpring notes
Spring notes
Rajeev Uppala
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
Mohit Gupta
 
How Spring Framework Really Works?
How Spring Framework Really Works?How Spring Framework Really Works?
How Spring Framework Really Works?
NexSoftsys
 
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of ControlJava Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Arjun Thakur
 
The Power of Enterprise Java Frameworks
The Power of Enterprise Java FrameworksThe Power of Enterprise Java Frameworks
The Power of Enterprise Java Frameworks
Clarence Ho
 
Spring intro classes-in-mumbai
Spring intro classes-in-mumbaiSpring intro classes-in-mumbai
Spring intro classes-in-mumbai
vibrantuser
 
Spring framework
Spring frameworkSpring framework
Spring framework
Kani Selvam
 
Spring - a framework written by developers
Spring - a framework written by developersSpring - a framework written by developers
Spring - a framework written by developers
MarcioSoaresPereira1
 
스프링 프레임워크
스프링 프레임워크스프링 프레임워크
스프링 프레임워크
Yoonki Chang
 
unit_1_spring_1.pptxfgfgggjffgggddddgggg
unit_1_spring_1.pptxfgfgggjffgggddddggggunit_1_spring_1.pptxfgfgggjffgggddddgggg
unit_1_spring_1.pptxfgfgggjffgggddddgggg
zmulani8
 
Introduction to Spring
Introduction to SpringIntroduction to Spring
Introduction to Spring
Sujit Kumar
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
Mukesh Kumar
 
Framework adoption for java enterprise application development
Framework adoption for java enterprise application developmentFramework adoption for java enterprise application development
Framework adoption for java enterprise application development
Clarence Ho
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
Mohit Gupta
 
How Spring Framework Really Works?
How Spring Framework Really Works?How Spring Framework Really Works?
How Spring Framework Really Works?
NexSoftsys
 
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of ControlJava Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Arjun Thakur
 
The Power of Enterprise Java Frameworks
The Power of Enterprise Java FrameworksThe Power of Enterprise Java Frameworks
The Power of Enterprise Java Frameworks
Clarence Ho
 
Ad

More from Manav Prasad (20)

Experience with mulesoft
Experience with mulesoftExperience with mulesoft
Experience with mulesoft
Manav Prasad
 
Mulesoftconnectors
MulesoftconnectorsMulesoftconnectors
Mulesoftconnectors
Manav Prasad
 
Mule and web services
Mule and web servicesMule and web services
Mule and web services
Manav Prasad
 
Mulesoft cloudhub
Mulesoft cloudhubMulesoft cloudhub
Mulesoft cloudhub
Manav Prasad
 
Perl tutorial
Perl tutorialPerl tutorial
Perl tutorial
Manav Prasad
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
Manav Prasad
 
Jpa
JpaJpa
Jpa
Manav Prasad
 
Json
Json Json
Json
Manav Prasad
 
The spring framework
The spring frameworkThe spring framework
The spring framework
Manav Prasad
 
Rest introduction
Rest introductionRest introduction
Rest introduction
Manav Prasad
 
Exceptions in java
Exceptions in javaExceptions in java
Exceptions in java
Manav Prasad
 
Junit
JunitJunit
Junit
Manav Prasad
 
Xml parsers
Xml parsersXml parsers
Xml parsers
Manav Prasad
 
Xpath
XpathXpath
Xpath
Manav Prasad
 
Xslt
XsltXslt
Xslt
Manav Prasad
 
Xhtml
XhtmlXhtml
Xhtml
Manav Prasad
 
Css
CssCss
Css
Manav Prasad
 
Introduction to html5
Introduction to html5Introduction to html5
Introduction to html5
Manav Prasad
 
Ajax
AjaxAjax
Ajax
Manav Prasad
 
J query
J queryJ query
J query
Manav Prasad
 

Recently uploaded (20)

Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 

Spring introduction

  • 2. Spring Overview • Spring is an open source layered Java/J2EE application framework • Created by Rod Johnson • Based on book “Expert one-on-one J2EE Design and Development” (October, 2002) • Current version 2.0.6 (released on 2007-06-18) • The Spring Framework is licensed under the terms of the Apache License, Version 2.0 and can be downloaded at: • http://www.springframework.org/download • Philosophy: J2EE should be easier to use, “Lightweight Container” concept A software framework is a re-usable design for a software system.
  • 3. What are Lightweight Frameworks? • Non-intrusive • No container requirements • Simplify application development • Remove re-occurring pattern code • Productivity friendly • Unit test friendly • Very pluggable • Usually open source • Examples: • Spring, Pico, Hivemind • Hibernate, IBatis, Castor • WebWork • Quartz • Sitemesh
  • 4. Spring Mission Statement • J2EE should be easier to use • It's best to program to interfaces, rather than classes. Spring reduces the complexity cost of using interfaces to zero. • JavaBeans offer a great way of configuring applications • OO design is more important than any implementation technology, such as J2EE • Checked exceptions are overused in Java. A framework shouldn't force you to catch exceptions you're unlikely to be able to recover from. • Testability is essential, and a framework such as Spring should help make your code easier to test • Spring should be a pleasure to use • Your application code should not depend on Spring APIs • Spring should not compete with good existing solutions, but should foster integration. (For example, JDO and Hibernate are great O/R mapping solutions. Don't need to develop another one).
  • 5. Modules of the Spring Framework The Spring Framework can be considered as a collection of frameworks-in-the-framework: • Core - Inversion of Control (IoC) and Dependency Injection • AOP - Aspect-oriented programming • DAO - Data Access Object support, transaction management, JDBC-abstraction • ORM - Object Relational Mapping data access, integration layers for JPA, JDO, Hibernate, and iBatis • MVC - Model-View-Controller implementation for web- applications • Remote Access, Authentication and Authorization, Remote Management, Messaging Framework, Web Services, Email, Testing, …
  • 6. Overview of the Spring Framework Very loosely coupled, components widely reusable and separately packaged.
  • 7. Spring Details • Spring allows to decouple software layers by injecting a component’s dependencies at runtime rather than having them declared at compile time via importing and instantiating classes. • Spring provides integration for J2EE services such as EJB, JDBC, JNDI, JMS, JTA. It also integrates several popular ORM toolkits such as Hibernate and JDO and assorted other services as well. • One of the highly touted features is declarative transactions, which allows the developer to write transaction-unaware code and configure transactions in Spring config files. • Spring is built on the principle of unchecked exception handling. This also reduces code dependencies between layers. Spring provides a granular exception hierarchy for data access operations and maps JDBC, EJB, and ORM exceptions to Spring exceptions so that applications can get better information about the error condition. • With highly decoupled software layers and programming to interfaces, each layer is easier to test. Mock objects is a testing pattern that is very useful in this regard.
  • 8. Advantages of Spring Architecture • Enable you to write powerful, scalable applications using POJOs • Lifecycle – responsible for managing all your application components, particularly those in the middle tier container sees components through well-defined lifecycle: init(), destroy() • Dependencies - Spring handles injecting dependent components without a component knowing where they came from (IoC) • Configuration information - Spring provides one consistent way of configuring everything, separate configuration from application logic, varying configuration • In J2EE (e.g. EJB) it is easy to become dependent on container and deployment environment, proliferation of pointless classes (locators/delegates); Spring eliminates them • Cross-cutting behavior (resource management is cross-cutting concern, easy to copy-and-paste everywhere) • Portable (can use server-side in web/ejb app, client-side in swing app, business logic is completely portable)
  • 9. Spring Solutions • Solutions address major J2EE problem areas: • Web application development (MVC) • Enterprise Java Beans (EJB, JNDI) • Database access (JDBC, iBatis, ORM) • Transaction management (JTA, Hibernate, JDBC) • Remote access (Web Services, RMI) • Each solution builds on the core architecture • Solutions foster integration, they do not re-invent the wheel
  • 10. How to Start Using Spring • Download Spring from www.springframework.org, e.g. spring-framework-2.0.6-with-dependencies.zip • Unzip to some location, e.g. C:toolsspring-framework-2.0.6 • Folder C:toolsspring-framework-2.0.6dist contains Spring distribution jar files • Add libraries to your application classpath and start programming with Spring
  • 11. Inversion of Control (IoC) • Central in the Spring is its Inversion of Control container • Based on “Inversion of Control Containers and the Dependency Injection pattern” (Martin Fowler) • Provides centralized, automated configuration, managing and wiring of application Java objects • Container responsibilities: • creating objects, • configuring objects, • calling initialization methods • passing objects to registered callback objects • etc • All together form the object lifecycle which is one of the most important features Java objects that are managed by the Spring IoC container are referred to as beans
  • 12. Dependency Injection – Non-IoC public class MainBookmarkProcessor implements BookmarkProcessor{ private PageDownloader pageDownloader; private RssParser rssParser; public List<Bookmark> loadBookmarks() { // direct initialization pageDownloader = new ApachePageDownloader(); rssParser = new JenaRssParser(); // or factory initialization // pageDownloader = PageDownloaderFactory.getPageDownloader(); // rssParser = RssParserFactory.getRssParser(); // use initialized objects pageDownloader.downloadPage(url); rssParser.extractBookmarks(fileName, resourceName); // ... }
  • 13. Dependency Injection - IoC • Beans define their dependencies through constructor arguments or properties • Container resolves (injects) dependencies of components by setting implementation object during runtime • BeanFactory interface - the core that loads bean definitions and manages beans • Most commonly used implementation is the XmlBeanFactory class • Allows to express the objects that compose application, and the interdependencies between such objects, in terms of XML • The XmlBeanFactory takes this XML configuration metadata and uses it to create a fully configured system
  • 14. Non-IoC versus IoC Non Inversion of Control approach Inversion of Control approach
  • 15. IoC Basics • Basic JavaBean pattern: • include a “getter” and “setter” method for each field: • Rather than locating needed resources, application components provide setters through which resources are passed in during initialization • In Spring Framework, this pattern is used extensively, and initialization is usually done through configuration file rather than application code class MyBean { private int counter; public int getCounter() { return counter; } public void setCounter(int counter) { this.counter = counter; } }
  • 16. IoC Java Bean public class MainBookmarkProcessor implements BookmarkProcessor{ private PageDownloader pageDownloader; private RssParser rssParser; public List<Bookmark> loadBookmarks() { pageDownloader.downloadPage(url); rssParser.extractBookmarks(fileName, resourceName); // ... } public void setPageDownloader(PageDownloader pageDownloader){ this.pageDownloader = pageDownloader; } public void setRssParser(RssParser rssParser){ this.rssParser = rssParser; }
  • 17. References • Spring Home: http://www.springframework.org • Inversion of Control Containers and the Dependency Injection pattern http://www.martinfowler.com/articles/injection.html • Spring IoC Container: http://static.springframework.org/spring/docs/2.0.x/referenc e/beans.html • Introduction to the Spring Framework by Rod Johnson http://www.theserverside.com/tt/articles/article.tss? l=SpringFramework