SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Spring Framework
Spring Overview
•

Spring is an open source layered Java/J2EE application
framework
A software framework is a re-usable

•

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:
•

•

design for a software system.

http://www.springframework.org/download

Philosophy: J2EE should be easier to use,
“Lightweight Container” concept
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 webapplications
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:
•
•
•
•
•

•

Java objects that are managed
by the Spring IoC container are
referred to as beans

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
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:
class MyBean {
private int counter;
public int getCounter()
{ return counter; }
public void setCounter(int counter)
{ this.counter = counter; }
}

•

•

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
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

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Ibatis by Rohit
Introduction to Ibatis by RohitIntroduction to Ibatis by Rohit
Introduction to Ibatis by RohitRohit Prabhakar
 
Spring framework
Spring frameworkSpring framework
Spring frameworkAircon Chen
 
스프링 프레임워크
스프링 프레임워크스프링 프레임워크
스프링 프레임워크Yoonki Chang
 
Spring core module
Spring core moduleSpring core module
Spring core moduleRaj Tomar
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring FrameworkHùng Nguyễn Huy
 
Spring framework
Spring frameworkSpring framework
Spring frameworkKani Selvam
 
Spring Framework Presantation Part 1-Core
Spring Framework Presantation Part 1-CoreSpring Framework Presantation Part 1-Core
Spring Framework Presantation Part 1-CoreDonald Lika
 
Java & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkJava & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkMohit Belwal
 
Lecture 1: Introduction to JEE
Lecture 1:  Introduction to JEELecture 1:  Introduction to JEE
Lecture 1: Introduction to JEEFahad Golra
 
Spring Framework
Spring FrameworkSpring Framework
Spring Frameworknomykk
 

Was ist angesagt? (19)

Introduction to Ibatis by Rohit
Introduction to Ibatis by RohitIntroduction to Ibatis by Rohit
Introduction to Ibatis by Rohit
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Java spring ppt
Java spring pptJava spring ppt
Java spring ppt
 
스프링 프레임워크
스프링 프레임워크스프링 프레임워크
스프링 프레임워크
 
Spring core module
Spring core moduleSpring core module
Spring core module
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Spring notes
Spring notesSpring notes
Spring notes
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Spring Framework Presantation Part 1-Core
Spring Framework Presantation Part 1-CoreSpring Framework Presantation Part 1-Core
Spring Framework Presantation Part 1-Core
 
Java & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkJava & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate Framework
 
Spring
SpringSpring
Spring
 
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
 
Spring Framework Training Course
Spring Framework Training Course Spring Framework Training Course
Spring Framework Training Course
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Spring framework core
Spring framework coreSpring framework core
Spring framework core
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Lecture 1: Introduction to JEE
Lecture 1:  Introduction to JEELecture 1:  Introduction to JEE
Lecture 1: Introduction to JEE
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 

Andere mochten auch

Spring introduction
Spring introductionSpring introduction
Spring introductionManav Prasad
 
Getting Started with Spring Framework
Getting Started with Spring FrameworkGetting Started with Spring Framework
Getting Started with Spring FrameworkEdureka!
 
SpringPeople Introduction to Spring Framework
SpringPeople Introduction to Spring FrameworkSpringPeople Introduction to Spring Framework
SpringPeople Introduction to Spring FrameworkSpringPeople
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework Serhat Can
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - CoreDzmitry Naskou
 

Andere mochten auch (8)

Spring introduction
Spring introductionSpring introduction
Spring introduction
 
Getting Started with Spring Framework
Getting Started with Spring FrameworkGetting Started with Spring Framework
Getting Started with Spring Framework
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
 
SpringPeople Introduction to Spring Framework
SpringPeople Introduction to Spring FrameworkSpringPeople Introduction to Spring Framework
SpringPeople Introduction to Spring Framework
 
Spring MVC Basics
Spring MVC BasicsSpring MVC Basics
Spring MVC Basics
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Spring ppt
Spring pptSpring ppt
Spring ppt
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 

Ähnlich wie Spring

Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworksMukesh 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 developmentClarence Ho
 
How Spring Framework Really Works?
How Spring Framework Really Works?How Spring Framework Really Works?
How Spring Framework Really Works?NexSoftsys
 
Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.suranisaunak
 
Introduction to Spring sec1.pptx
Introduction to Spring sec1.pptxIntroduction to Spring sec1.pptx
Introduction to Spring sec1.pptxNourhanTarek23
 
Spring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsSpring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsVirtual Nuggets
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC frameworkMohit Gupta
 
TheSpringFramework
TheSpringFrameworkTheSpringFramework
TheSpringFrameworkShankar Nair
 
Spring presentecion isil
Spring presentecion isilSpring presentecion isil
Spring presentecion isilWilly Aguirre
 
Spring presentecion isil
Spring presentecion isilSpring presentecion isil
Spring presentecion isilWilly Aguirre
 
Spring framework Introduction
Spring framework  IntroductionSpring framework  Introduction
Spring framework IntroductionAnuj Singh Rajput
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring FrameworkDineesha Suraweera
 
Jetspeed-2 Overview
Jetspeed-2 OverviewJetspeed-2 Overview
Jetspeed-2 Overviewbettlebrox
 
The Power of Enterprise Java Frameworks
The Power of Enterprise Java FrameworksThe Power of Enterprise Java Frameworks
The Power of Enterprise Java FrameworksClarence Ho
 

Ähnlich wie Spring (20)

Java Spring
Java SpringJava Spring
Java Spring
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
 
spring
springspring
spring
 
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
 
Introduction to Spring & Spring BootFramework
Introduction to Spring  & Spring BootFrameworkIntroduction to Spring  & Spring BootFramework
Introduction to Spring & Spring BootFramework
 
How Spring Framework Really Works?
How Spring Framework Really Works?How Spring Framework Really Works?
How Spring Framework Really Works?
 
Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.
 
Introduction to Spring sec1.pptx
Introduction to Spring sec1.pptxIntroduction to Spring sec1.pptx
Introduction to Spring sec1.pptx
 
Spring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsSpring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggets
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
 
TheSpringFramework
TheSpringFrameworkTheSpringFramework
TheSpringFramework
 
Spring presentecion isil
Spring presentecion isilSpring presentecion isil
Spring presentecion isil
 
Spring presentecion isil
Spring presentecion isilSpring presentecion isil
Spring presentecion isil
 
Spring framework Introduction
Spring framework  IntroductionSpring framework  Introduction
Spring framework Introduction
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Spring 2
Spring 2Spring 2
Spring 2
 
Jetspeed-2 Overview
Jetspeed-2 OverviewJetspeed-2 Overview
Jetspeed-2 Overview
 
The Power of Enterprise Java Frameworks
The Power of Enterprise Java FrameworksThe Power of Enterprise Java Frameworks
The Power of Enterprise Java Frameworks
 
Oracle Data Integrator
Oracle Data Integrator Oracle Data Integrator
Oracle Data Integrator
 
Spring
SpringSpring
Spring
 

Kürzlich hochgeladen

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Kürzlich hochgeladen (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

Spring

  • 2. Spring Overview • Spring is an open source layered Java/J2EE application framework A software framework is a re-usable • 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: • • design for a software system. http://www.springframework.org/download Philosophy: J2EE should be easier to use, “Lightweight Container” concept
  • 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 webapplications 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: • • • • • • Java objects that are managed by the Spring IoC container are referred to as beans 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
  • 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: class MyBean { private int counter; public int getCounter() { return counter; } public void setCounter(int counter) { this.counter = counter; } } • • 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
  • 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