SlideShare a Scribd company logo
Spring Framework
Vibrant Technology & Computers 1
Vibrant
Technology
&
Computers
Vibrant Technology & Computers 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.
Vibrant Technology & Computers 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
Vibrant Technology & Computers 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).
Vibrant Technology & Computers 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, …
Vibrant Technology & Computers 6
Overview of the Spring Framework
Very loosely coupled, components widely reusable and
separately packaged.
Vibrant Technology & Computers 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.
Vibrant Technology & Computers 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)
Vibrant Technology & Computers 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
Vibrant Technology & Computers 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
Vibrant Technology & Computers 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
Vibrant Technology & Computers 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);
// ...
}
Vibrant Technology & Computers 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
Vibrant Technology & Computers 14
Non-IoC versus IoC
Non Inversion of Control
approach
Inversion of Control
approach
Vibrant Technology & Computers 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; }
}
Vibrant Technology & Computers 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;
}
Vibrant Technology & Computers 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
Vibrant Technology & Computers 18
Thank you…
Vibrant Technology & Computers 19

More Related Content

PPT
PPT
Hybernat and structs, spring classes in mumbai
ODP
Introduction to Spring Framework and Spring IoC
PDF
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
PPTX
Spring framework
PPT
Lecture 19 dynamic web - java - part 1
PPTX
Spring
PDF
jsf2 Notes
Hybernat and structs, spring classes in mumbai
Introduction to Spring Framework and Spring IoC
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
Spring framework
Lecture 19 dynamic web - java - part 1
Spring
jsf2 Notes

What's hot (19)

PPSX
Intorduction to struts
PDF
Java Enterprise Edition 6 Overview
PDF
Liferay architecture By Navin Agarwal
PPTX
Portlet Framework: the Liferay way
PDF
Introduction to Portlets Using Liferay Portal
ODP
Liferay and Cloud
PDF
OOW 2009 Using FMW EBS R12
PPTX
Java Spring
PPT
JEE Course - JEE Overview
PPTX
The Latest in Enterprise JavaBeans Technology
PDF
JavaOne 2011: Migrating Spring Applications to Java EE 6
PPTX
Developing Enterprise Applications Using Java Technology
PPT
The Top 10 Things Oracle UCM Users Need To Know About WebLogic
PPTX
Building 12-factor Cloud Native Microservices
PPTX
Workshop OSGI PPT
PPTX
Best Practices for JSF, Gameduell 2013
ODT
Spring framework
PPTX
Migrating From Applets to Java Desktop Apps in JavaFX
PDF
Java on Azure
Intorduction to struts
Java Enterprise Edition 6 Overview
Liferay architecture By Navin Agarwal
Portlet Framework: the Liferay way
Introduction to Portlets Using Liferay Portal
Liferay and Cloud
OOW 2009 Using FMW EBS R12
Java Spring
JEE Course - JEE Overview
The Latest in Enterprise JavaBeans Technology
JavaOne 2011: Migrating Spring Applications to Java EE 6
Developing Enterprise Applications Using Java Technology
The Top 10 Things Oracle UCM Users Need To Know About WebLogic
Building 12-factor Cloud Native Microservices
Workshop OSGI PPT
Best Practices for JSF, Gameduell 2013
Spring framework
Migrating From Applets to Java Desktop Apps in JavaFX
Java on Azure
Ad

Viewers also liked (20)

PDF
1213454 한자연 디자인과 문화 보고서
PDF
숙명여자대학교 디자인과 문화 보고서 1213454 한자연
PPTX
Spring framework v2
PPTX
[명우니닷컴]DB-휘트니스센터-데이터모델링
PDF
Effective Persistence Using ORM With Hibernate
PDF
컬러배스 4444
PDF
실리콘밸리의 한국인 2015 - 권기태 발표
PPSX
TheSpringFramework
PDF
Leverage Hibernate and Spring Features Together
PPT
협동조합역할극워크숍
PPTX
Skillwise-Spring framework 1
PPT
Spring overview &amp; architecture
PDF
Building Web Application Using Spring Framework
PPTX
Go lang(goroutine, channel, 동기화 객체)
PDF
Smart work
PDF
Link prediction 방법의 개념 및 활용
PPTX
Introduction to Spring Framework
PDF
Spring framework
PDF
Getting Started with Spring Framework
PDF
[코딩카페]웹접근성 이해하기 유정식
1213454 한자연 디자인과 문화 보고서
숙명여자대학교 디자인과 문화 보고서 1213454 한자연
Spring framework v2
[명우니닷컴]DB-휘트니스센터-데이터모델링
Effective Persistence Using ORM With Hibernate
컬러배스 4444
실리콘밸리의 한국인 2015 - 권기태 발표
TheSpringFramework
Leverage Hibernate and Spring Features Together
협동조합역할극워크숍
Skillwise-Spring framework 1
Spring overview &amp; architecture
Building Web Application Using Spring Framework
Go lang(goroutine, channel, 동기화 객체)
Smart work
Link prediction 방법의 개념 및 활용
Introduction to Spring Framework
Spring framework
Getting Started with Spring Framework
[코딩카페]웹접근성 이해하기 유정식
Ad

Similar to Spring intro classes-in-mumbai (20)

PPT
Spring introduction
PPT
Spring ppt
PPT
Spring - a framework written by developers
PPTX
Spring Framework Rohit
PDF
Spring Framework Tutorial | VirtualNuggets
PPT
Learn spring at amc square learning
PPTX
Introduction to Spring Framework
PPTX
spring
DOCX
Spring notes
PPTX
Spring
PPTX
1. Spring intro IoC
 
PDF
Spring presentecion isil
PDF
Spring presentecion isil
PPT
Spring Framework
PPTX
Introduction to j2 ee frameworks
PPTX
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
PPTX
Spring basics for freshers
PPTX
Spring framework Introduction
PPTX
unit_1_spring_1.pptxfgfgggjffgggddddgggg
PDF
Spring framework Introduction
Spring introduction
Spring ppt
Spring - a framework written by developers
Spring Framework Rohit
Spring Framework Tutorial | VirtualNuggets
Learn spring at amc square learning
Introduction to Spring Framework
spring
Spring notes
Spring
1. Spring intro IoC
 
Spring presentecion isil
Spring presentecion isil
Spring Framework
Introduction to j2 ee frameworks
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Spring basics for freshers
Spring framework Introduction
unit_1_spring_1.pptxfgfgggjffgggddddgggg
Spring framework Introduction

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPT
Teaching material agriculture food technology
PPTX
Cloud computing and distributed systems.
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Electronic commerce courselecture one. Pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
The Rise and Fall of 3GPP – Time for a Sabbatical?
NewMind AI Weekly Chronicles - August'25-Week II
Teaching material agriculture food technology
Cloud computing and distributed systems.
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
“AI and Expert System Decision Support & Business Intelligence Systems”
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
MIND Revenue Release Quarter 2 2025 Press Release
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Electronic commerce courselecture one. Pdf
The AUB Centre for AI in Media Proposal.docx
Network Security Unit 5.pdf for BCA BBA.
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Review of recent advances in non-invasive hemoglobin estimation
sap open course for s4hana steps from ECC to s4
Mobile App Security Testing_ A Comprehensive Guide.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11

Spring intro classes-in-mumbai

  • 3. 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. Vibrant Technology & Computers 3
  • 4. 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 Vibrant Technology & Computers 4
  • 5. 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). Vibrant Technology & Computers 5
  • 6. 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, … Vibrant Technology & Computers 6
  • 7. Overview of the Spring Framework Very loosely coupled, components widely reusable and separately packaged. Vibrant Technology & Computers 7
  • 8. 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. Vibrant Technology & Computers 8
  • 9. 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) Vibrant Technology & Computers 9
  • 10. 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 Vibrant Technology & Computers 10
  • 11. 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 Vibrant Technology & Computers 11
  • 12. 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 Vibrant Technology & Computers 12
  • 13. 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); // ... } Vibrant Technology & Computers 13
  • 14. 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 Vibrant Technology & Computers 14
  • 15. Non-IoC versus IoC Non Inversion of Control approach Inversion of Control approach Vibrant Technology & Computers 15
  • 16. 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; } } Vibrant Technology & Computers 16
  • 17. 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; } Vibrant Technology & Computers 17
  • 18. 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 Vibrant Technology & Computers 18