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

What's hot (19)

Intorduction to struts
Intorduction to strutsIntorduction to struts
Intorduction to struts
Anup72
 
Java Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewJava Enterprise Edition 6 Overview
Java Enterprise Edition 6 Overview
Eugene Bogaart
 
Liferay architecture By Navin Agarwal
Liferay architecture By Navin AgarwalLiferay architecture By Navin Agarwal
Liferay architecture By Navin Agarwal
Navin Agarwal
 
Portlet Framework: the Liferay way
Portlet Framework: the Liferay wayPortlet Framework: the Liferay way
Portlet Framework: the Liferay way
riround
 
Introduction to Portlets Using Liferay Portal
Introduction to Portlets Using Liferay PortalIntroduction to Portlets Using Liferay Portal
Introduction to Portlets Using Liferay Portal
rivetlogic
 
Liferay and Cloud
Liferay and CloudLiferay and Cloud
Liferay and Cloud
Miguel Pastor
 
OOW 2009 Using FMW EBS R12
OOW 2009 Using FMW EBS R12OOW 2009 Using FMW EBS R12
OOW 2009 Using FMW EBS R12
jucaab
 
Java Spring
Java SpringJava Spring
Java Spring
AathikaJava
 
JEE Course - JEE Overview
JEE Course - JEE  OverviewJEE Course - JEE  Overview
JEE Course - JEE Overview
odedns
 
The Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologyThe Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans Technology
Simon Ritter
 
JavaOne 2011: Migrating Spring Applications to Java EE 6
JavaOne 2011: Migrating Spring Applications to Java EE 6JavaOne 2011: Migrating Spring Applications to Java EE 6
JavaOne 2011: Migrating Spring Applications to Java EE 6
Bert Ertman
 
Developing Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java TechnologyDeveloping Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java Technology
Simon Ritter
 
The Top 10 Things Oracle UCM Users Need To Know About WebLogic
The Top 10 Things Oracle UCM Users Need To Know About WebLogicThe Top 10 Things Oracle UCM Users Need To Know About WebLogic
The Top 10 Things Oracle UCM Users Need To Know About WebLogic
Brian Huff
 
Building 12-factor Cloud Native Microservices
Building 12-factor Cloud Native MicroservicesBuilding 12-factor Cloud Native Microservices
Building 12-factor Cloud Native Microservices
Jakarta_EE
 
Workshop OSGI PPT
Workshop OSGI PPTWorkshop OSGI PPT
Workshop OSGI PPT
Summer Lu
 
Best Practices for JSF, Gameduell 2013
Best Practices for JSF, Gameduell 2013Best Practices for JSF, Gameduell 2013
Best Practices for JSF, Gameduell 2013
Edward Burns
 
Spring framework
Spring frameworkSpring framework
Spring framework
Shivi Kashyap
 
Migrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFXMigrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFX
Bruno Borges
 
Java on Azure
Java on AzureJava on Azure
Java on Azure
Philly JUG
 
Intorduction to struts
Intorduction to strutsIntorduction to struts
Intorduction to struts
Anup72
 
Java Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewJava Enterprise Edition 6 Overview
Java Enterprise Edition 6 Overview
Eugene Bogaart
 
Liferay architecture By Navin Agarwal
Liferay architecture By Navin AgarwalLiferay architecture By Navin Agarwal
Liferay architecture By Navin Agarwal
Navin Agarwal
 
Portlet Framework: the Liferay way
Portlet Framework: the Liferay wayPortlet Framework: the Liferay way
Portlet Framework: the Liferay way
riround
 
Introduction to Portlets Using Liferay Portal
Introduction to Portlets Using Liferay PortalIntroduction to Portlets Using Liferay Portal
Introduction to Portlets Using Liferay Portal
rivetlogic
 
OOW 2009 Using FMW EBS R12
OOW 2009 Using FMW EBS R12OOW 2009 Using FMW EBS R12
OOW 2009 Using FMW EBS R12
jucaab
 
JEE Course - JEE Overview
JEE Course - JEE  OverviewJEE Course - JEE  Overview
JEE Course - JEE Overview
odedns
 
The Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologyThe Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans Technology
Simon Ritter
 
JavaOne 2011: Migrating Spring Applications to Java EE 6
JavaOne 2011: Migrating Spring Applications to Java EE 6JavaOne 2011: Migrating Spring Applications to Java EE 6
JavaOne 2011: Migrating Spring Applications to Java EE 6
Bert Ertman
 
Developing Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java TechnologyDeveloping Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java Technology
Simon Ritter
 
The Top 10 Things Oracle UCM Users Need To Know About WebLogic
The Top 10 Things Oracle UCM Users Need To Know About WebLogicThe Top 10 Things Oracle UCM Users Need To Know About WebLogic
The Top 10 Things Oracle UCM Users Need To Know About WebLogic
Brian Huff
 
Building 12-factor Cloud Native Microservices
Building 12-factor Cloud Native MicroservicesBuilding 12-factor Cloud Native Microservices
Building 12-factor Cloud Native Microservices
Jakarta_EE
 
Workshop OSGI PPT
Workshop OSGI PPTWorkshop OSGI PPT
Workshop OSGI PPT
Summer Lu
 
Best Practices for JSF, Gameduell 2013
Best Practices for JSF, Gameduell 2013Best Practices for JSF, Gameduell 2013
Best Practices for JSF, Gameduell 2013
Edward Burns
 
Migrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFXMigrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFX
Bruno Borges
 

Viewers also liked (20)

1213454 한자연 디자인과 문화 보고서
1213454 한자연 디자인과 문화 보고서1213454 한자연 디자인과 문화 보고서
1213454 한자연 디자인과 문화 보고서
자연 한
 
숙명여자대학교 디자인과 문화 보고서 1213454 한자연
숙명여자대학교 디자인과 문화 보고서 1213454 한자연숙명여자대학교 디자인과 문화 보고서 1213454 한자연
숙명여자대학교 디자인과 문화 보고서 1213454 한자연
자연 한
 
Spring framework v2
Spring framework v2Spring framework v2
Spring framework v2
Yaroslav Hulaga
 
[명우니닷컴]DB-휘트니스센터-데이터모델링
[명우니닷컴]DB-휘트니스센터-데이터모델링[명우니닷컴]DB-휘트니스센터-데이터모델링
[명우니닷컴]DB-휘트니스센터-데이터모델링
Myeongun Ryu
 
Effective Persistence Using ORM With Hibernate
Effective Persistence Using ORM With HibernateEffective Persistence Using ORM With Hibernate
Effective Persistence Using ORM With Hibernate
Edureka!
 
컬러배스 4444
컬러배스 4444컬러배스 4444
컬러배스 4444
Moondajung
 
실리콘밸리의 한국인 2015 - 권기태 발표
실리콘밸리의 한국인 2015 - 권기태 발표실리콘밸리의 한국인 2015 - 권기태 발표
실리콘밸리의 한국인 2015 - 권기태 발표
StartupAlliance
 
TheSpringFramework
TheSpringFrameworkTheSpringFramework
TheSpringFramework
Shankar Nair
 
Leverage Hibernate and Spring Features Together
Leverage Hibernate and Spring Features TogetherLeverage Hibernate and Spring Features Together
Leverage Hibernate and Spring Features Together
Edureka!
 
협동조합역할극워크숍
협동조합역할극워크숍협동조합역할극워크숍
협동조합역할극워크숍
수원 주
 
Skillwise-Spring framework 1
Skillwise-Spring framework 1Skillwise-Spring framework 1
Skillwise-Spring framework 1
Skillwise Group
 
Spring overview &amp; architecture
Spring  overview &amp; architectureSpring  overview &amp; architecture
Spring overview &amp; architecture
saurabhshcs
 
Building Web Application Using Spring Framework
Building Web Application Using Spring FrameworkBuilding Web Application Using Spring Framework
Building Web Application Using Spring Framework
Edureka!
 
Go lang(goroutine, channel, 동기화 객체)
Go lang(goroutine, channel, 동기화 객체)Go lang(goroutine, channel, 동기화 객체)
Go lang(goroutine, channel, 동기화 객체)
seungkyu park
 
Smart work
Smart workSmart work
Smart work
오석 한
 
Link prediction 방법의 개념 및 활용
Link prediction 방법의 개념 및 활용Link prediction 방법의 개념 및 활용
Link prediction 방법의 개념 및 활용
Kyunghoon Kim
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Serhat Can
 
Spring framework
Spring frameworkSpring framework
Spring framework
Aircon Chen
 
Getting Started with Spring Framework
Getting Started with Spring FrameworkGetting Started with Spring Framework
Getting Started with Spring Framework
Edureka!
 
[코딩카페]웹접근성 이해하기 유정식
[코딩카페]웹접근성 이해하기 유정식[코딩카페]웹접근성 이해하기 유정식
[코딩카페]웹접근성 이해하기 유정식
jeong-sic Yoo
 
1213454 한자연 디자인과 문화 보고서
1213454 한자연 디자인과 문화 보고서1213454 한자연 디자인과 문화 보고서
1213454 한자연 디자인과 문화 보고서
자연 한
 
숙명여자대학교 디자인과 문화 보고서 1213454 한자연
숙명여자대학교 디자인과 문화 보고서 1213454 한자연숙명여자대학교 디자인과 문화 보고서 1213454 한자연
숙명여자대학교 디자인과 문화 보고서 1213454 한자연
자연 한
 
[명우니닷컴]DB-휘트니스센터-데이터모델링
[명우니닷컴]DB-휘트니스센터-데이터모델링[명우니닷컴]DB-휘트니스센터-데이터모델링
[명우니닷컴]DB-휘트니스센터-데이터모델링
Myeongun Ryu
 
Effective Persistence Using ORM With Hibernate
Effective Persistence Using ORM With HibernateEffective Persistence Using ORM With Hibernate
Effective Persistence Using ORM With Hibernate
Edureka!
 
컬러배스 4444
컬러배스 4444컬러배스 4444
컬러배스 4444
Moondajung
 
실리콘밸리의 한국인 2015 - 권기태 발표
실리콘밸리의 한국인 2015 - 권기태 발표실리콘밸리의 한국인 2015 - 권기태 발표
실리콘밸리의 한국인 2015 - 권기태 발표
StartupAlliance
 
TheSpringFramework
TheSpringFrameworkTheSpringFramework
TheSpringFramework
Shankar Nair
 
Leverage Hibernate and Spring Features Together
Leverage Hibernate and Spring Features TogetherLeverage Hibernate and Spring Features Together
Leverage Hibernate and Spring Features Together
Edureka!
 
협동조합역할극워크숍
협동조합역할극워크숍협동조합역할극워크숍
협동조합역할극워크숍
수원 주
 
Skillwise-Spring framework 1
Skillwise-Spring framework 1Skillwise-Spring framework 1
Skillwise-Spring framework 1
Skillwise Group
 
Spring overview &amp; architecture
Spring  overview &amp; architectureSpring  overview &amp; architecture
Spring overview &amp; architecture
saurabhshcs
 
Building Web Application Using Spring Framework
Building Web Application Using Spring FrameworkBuilding Web Application Using Spring Framework
Building Web Application Using Spring Framework
Edureka!
 
Go lang(goroutine, channel, 동기화 객체)
Go lang(goroutine, channel, 동기화 객체)Go lang(goroutine, channel, 동기화 객체)
Go lang(goroutine, channel, 동기화 객체)
seungkyu park
 
Link prediction 방법의 개념 및 활용
Link prediction 방법의 개념 및 활용Link prediction 방법의 개념 및 활용
Link prediction 방법의 개념 및 활용
Kyunghoon Kim
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Serhat Can
 
Spring framework
Spring frameworkSpring framework
Spring framework
Aircon Chen
 
Getting Started with Spring Framework
Getting Started with Spring FrameworkGetting Started with Spring Framework
Getting Started with Spring Framework
Edureka!
 
[코딩카페]웹접근성 이해하기 유정식
[코딩카페]웹접근성 이해하기 유정식[코딩카페]웹접근성 이해하기 유정식
[코딩카페]웹접근성 이해하기 유정식
jeong-sic Yoo
 

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

Spring introduction
Spring introductionSpring introduction
Spring introduction
Manav Prasad
 
Spring - a framework written by developers
Spring - a framework written by developersSpring - a framework written by developers
Spring - a framework written by developers
MarcioSoaresPereira1
 
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
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
Mukesh Kumar
 
A presentationon SPRING-BOOT and CRUD operation
A presentationon SPRING-BOOT and CRUD operationA presentationon SPRING-BOOT and CRUD operation
A presentationon SPRING-BOOT and CRUD operation
AbhijiteDebBarman
 
spring
springspring
spring
Suman Behara
 
스프링 프레임워크
스프링 프레임워크스프링 프레임워크
스프링 프레임워크
Yoonki Chang
 
Spring ppt
Spring pptSpring ppt
Spring ppt
Mumbai Academisc
 
Oracle Data Integrator
Oracle Data Integrator Oracle Data Integrator
Oracle Data Integrator
IT Help Desk Inc
 
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
 
Spring Framework Rohit
Spring Framework RohitSpring Framework Rohit
Spring Framework Rohit
Rohit Prabhakar
 
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
 
Introduction to Spring & Spring BootFramework
Introduction to Spring  & Spring BootFrameworkIntroduction to Spring  & Spring BootFramework
Introduction to Spring & Spring BootFramework
Kongu Engineering College, Perundurai, Erode
 
Chapter 10:Understanding Java Related Platforms and Integration Technologies
Chapter 10:Understanding Java Related Platforms and Integration TechnologiesChapter 10:Understanding Java Related Platforms and Integration Technologies
Chapter 10:Understanding Java Related Platforms and Integration Technologies
It Academy
 
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud EnvironmentsTools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
VMware Tanzu
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
Mohit Gupta
 
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
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
ASG
 
Spring notes
Spring notesSpring notes
Spring notes
Rajeev Uppala
 
Spring introduction
Spring introductionSpring introduction
Spring introduction
Manav Prasad
 
Spring - a framework written by developers
Spring - a framework written by developersSpring - a framework written by developers
Spring - a framework written by developers
MarcioSoaresPereira1
 
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
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
Mukesh Kumar
 
A presentationon SPRING-BOOT and CRUD operation
A presentationon SPRING-BOOT and CRUD operationA presentationon SPRING-BOOT and CRUD operation
A presentationon SPRING-BOOT and CRUD operation
AbhijiteDebBarman
 
스프링 프레임워크
스프링 프레임워크스프링 프레임워크
스프링 프레임워크
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
 
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
 
Chapter 10:Understanding Java Related Platforms and Integration Technologies
Chapter 10:Understanding Java Related Platforms and Integration TechnologiesChapter 10:Understanding Java Related Platforms and Integration Technologies
Chapter 10:Understanding Java Related Platforms and Integration Technologies
It Academy
 
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud EnvironmentsTools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
VMware Tanzu
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
Mohit Gupta
 
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
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
ASG
 

Recently uploaded (20)

Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
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
 
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
 
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
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
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.
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
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
 
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
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
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
 
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
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
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
 
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
 
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
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
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.
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
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
 
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
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
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
 
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
 

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