SlideShare une entreprise Scribd logo
1  sur  32
Spring Framework
Dineesha Suraweera
What is a framework ?
framework is a universal, reusable software environment that provides
particular functionality as part of a larger software platform to facilitate
development of software applications, products and solutions.
Software frameworks may include
support programs
compilers
code libraries
tool sets 2
How to separate framework from library ….
❏Inversion Control: In a framework, unlike in libraries the overall program's flow control is not
dictated by the caller, but by the framework.
❏default behavior
❏extensibility: can be extended by the user usually by selective overriding or specialized by user
code to provide specific functionality.
❏non-modifiable framework code: The framework code, in general, is not supposed to be
modified, while accepting user-implemented extensions.
3
Spring framework
Spring is the most popular application development framework for
enterprise Java.
open source Java platform
initially written by Rod Johnson and was first released under the Apache 2.0
license in June 2003.
lightweight when it comes to size and transparency.
4
Where to use ?
can be used in developing any Java application, but there are extensions for
building web applications on top of the Java EE platform.
Spring framework targets to make J2EE development easier to use and promote
good programming practice by enabling a POJO-based programming model.
5
Benefits of spring..
Spring is organized in a modular fashion
makes use of technologies like several ORM frameworks, logging
frameworks, JEE, Quartz and JDK timers, other view technologies
Testing an application written with Spring is simple
Spring's web framework is a well-designed web MVC framework
provides a convenient API to translate technology-specific exceptions into
consistent, unchecked exceptions
6
Architecture
7
Description of architecture
Core Container
Core provides the fundamental parts of the framework, including the IoC and Dependency
Injection features.
Bean provides BeanFactory which is a sophisticated implementation of the factory pattern.
Context builds on the solid base provided by the Core and Beans modules and it is a medium to
access any objects defined and configured.
SpEL module provides a powerful expression language for querying and manipulating an object
graph at runtime.
8
Data Access/Integration
JDBC provides a JDBC-abstraction layer that removes the need to do tedious JDBC related coding.
ORM provides integration layers for popular object-relational mapping APIs, including JPA, JDO,
Hibernate, and iBatis.
OXM provides an abstraction layer that supports Object/XML mapping implementations for JAXB,
Castor, XMLBeans, JiBX and XStream.
JMS contains features for producing and consuming messages.
Transaction supports programmatic and declarative transaction management for classes that
implement special interfaces and for all your POJOs.
9
Web
Web provides basic web-oriented integration features such as multipart file-upload functionality
and the initialization of the IoC container using servlet listeners and a web-oriented application
context.
Web-MVC contains Spring's model-view-controller (MVC) implementation for web applications.
Web-Socket provides support for WebSocket-based, two-way communication between client and
server in web applications.
Web-Portlet provides the MVC implementation to be used in a portlet environment and mirrors
the functionality of Web-Servlet module.
10
pre-requisites
Java Development Kit (JDK)
Apache Common Logging API
http://commons.apache.org/proper/commons-logging/download_logging.cgi
Spring Framework Libraries
http://repo.spring.io/release/org/springframework/spring/
11
How to use
1. Create java project
1. Add required libraries
12
3. Create source files.
4. Create Bean configuration file
13
14
15
Spring with maven
If you are using Maven for dependency management you don’t even need to supply the logging
dependency explicitly.
To create an application context and use dependency injection to configure an application
16
IoC Containers
Core of the Spring Framework
The container will create the objects, wire them together, configure them, and
manage their complete lifecycle from creation till destruction.
17
uses dependency injection (DI) to manage the components that make up an
application(spring Beans)
Spring BeanFactory Container
simplest container providing basic support for DI and defined by the
org.springframework.beans.factory.BeanFactory interface. The BeanFactory and related interfaces, such as
BeanFactoryAware, InitializingBean, DisposableBean, are still present in Spring for the purposes of backward
compatibility with the large number of third-party frameworks that integrate with Spring.
Spring ApplicationContext Container
adds more enterprise-specific functionality such as the ability to resolve textual messages from a properties file
and the ability to publish application events to interested event listeners. This container is defined by the
org.springframework.context.ApplicationContext interface.
18
Benefits of IoC/DI
Reduced Dependencies
Reduced Dependency Carrying
More Reusable Code
More Testable Code
More Readable Code
19
Bean Definition
A bean is an object that is instantiated, assembled, and otherwise managed by
a Spring IoC container.
The bean definition contains the information called configuration metadata
which is needed for the container to know the followings
How to create a bean
Bean's lifecycle details
Bean's dependencies
20
Spring Configuration Metadata
There are three important methods to provide configuration metadata to the
Spring Container
XML based configuration file.
Annotation-based configuration
Java-based configuration
21
22
Annotation based configuration
To describe a bean wiring,move the bean configuration into the component
class itself by using annotations on the relevant class, method, or field
declaration.
Annotation wiring is not turned on in the Spring container by default
23
Basic annotations
@Required
The @Required annotation applies to bean property setter methods.
@Autowired
The @Autowired annotation can apply to bean property setter methods, non-setter methods, constructor and
properties.
@Qualifier
The @Qualifier annotation along with @Autowired can be used to remove the confusion by specifying which exact
bean will be wired.
JSR-250 Annotations
Spring supports JSR-250 based annotations which include @Resource, @PostConstruct and @PreDestroy
annotations. 24
Java based configuration
Java based configuration option enables you to write most of your Spring
configuration without XML but with the help of few Java-based annotations
@Configuration
class can be used by the Spring IoC container as a source of bean definitions
@Bean Annotations
return an object that should be registered as a bean in the Spring application context.
@Import Annotation
25
Dependency Injection
The Dependency Injection is a design pattern that removes the dependency of
the programs. In such case we provide the information from the external
source such as XML file. It makes our code loosely coupled and easier for
testing.
Spring framework provides two ways to inject dependency
By Constructor
By Setter method
26
In such case, instance of Address class is provided by external source such as
XML file either by constructor or setter method.
27
Beans auto-wiring
Enables you to inject the object dependency implicitly. It internally uses setter or constructor
injection.
Autowiring can't be used to inject primitive and string values. It works with reference only.
28
AOP with Spring Framework
Aspect Oriented Programming entails breaking down program logic into
distinct parts.(like logging, auditing, declarative transactions, security, and
caching etc)
Spring AOP module provides interceptors to intercept an application, when a
method is executed, you can add extra functionality before or after the
method execution.
29
Demo
30
Other Spring projects
Spring Cloud
Spring Data
Spring Security
Spring Social
Spring Mobile
Spring Session
Spring Shell
31
Thank You!
32

Contenu connexe

Tendances

Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introductionRasheed Waraich
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring FrameworkASG
 
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 ControlArjun Thakur
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - CoreDzmitry Naskou
 
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 Framework Serhat Can
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introductionJonathan Holloway
 
Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Hitesh-Java
 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depthVinay Kumar
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring FrameworkHùng Nguyễn Huy
 
Spring framework Introduction
Spring framework IntroductionSpring framework Introduction
Spring framework IntroductionAnuj Singh Rajput
 

Tendances (20)

Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
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
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Spring boot
Spring bootSpring boot
Spring boot
 
Java Spring
Java SpringJava Spring
Java Spring
 
Spring boot
Spring bootSpring boot
Spring boot
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Spring core module
Spring core moduleSpring core module
Spring core module
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring notes
Spring notesSpring notes
Spring notes
 
Xke spring boot
Xke spring bootXke spring boot
Xke spring boot
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
 
Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans
 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depth
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
Spring boot
Spring bootSpring boot
Spring boot
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Spring framework Introduction
Spring framework IntroductionSpring framework Introduction
Spring framework Introduction
 

En vedette (20)

Getting Started with Spring Framework
Getting Started with Spring FrameworkGetting Started with Spring Framework
Getting Started with Spring Framework
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
Springs
SpringsSprings
Springs
 
Presentation Spring
Presentation SpringPresentation Spring
Presentation Spring
 
Spring framework core
Spring framework coreSpring framework core
Spring framework core
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC Annotations
 
Spring 4 - A&BP CC
Spring 4 - A&BP CCSpring 4 - A&BP CC
Spring 4 - A&BP CC
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
 
Next stop: Spring 4
Next stop: Spring 4Next stop: Spring 4
Next stop: Spring 4
 
Spring MVC - The Basics
Spring MVC -  The BasicsSpring MVC -  The Basics
Spring MVC - The Basics
 
Presentation Spring, Spring MVC
Presentation Spring, Spring MVCPresentation Spring, Spring MVC
Presentation Spring, Spring MVC
 
Spring MVC Basics
Spring MVC BasicsSpring MVC Basics
Spring MVC Basics
 
Spring MVC 3.0 Framework
Spring MVC 3.0 FrameworkSpring MVC 3.0 Framework
Spring MVC 3.0 Framework
 
Spring tutorial
Spring tutorialSpring tutorial
Spring tutorial
 
Spring Framework Essentials
Spring Framework EssentialsSpring Framework Essentials
Spring Framework Essentials
 
Sectors of indian economy
Sectors of indian economySectors of indian economy
Sectors of indian economy
 
nationalism movement in Indochina
nationalism movement in Indochina nationalism movement in Indochina
nationalism movement in Indochina
 
Spock
SpockSpock
Spock
 
Physicalfeaturesofindia
Physicalfeaturesofindia Physicalfeaturesofindia
Physicalfeaturesofindia
 
Spring framework
Spring frameworkSpring framework
Spring framework
 

Similaire à Introduction to Spring Framework

Session 43 - Spring - Part 1 - IoC DI Beans
Session 43 - Spring - Part 1 - IoC DI BeansSession 43 - Spring - Part 1 - IoC DI Beans
Session 43 - Spring - Part 1 - IoC DI BeansPawanMM
 
Spring (1)
Spring (1)Spring (1)
Spring (1)Aneega
 
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
 
spring framework ppt by Rohit malav
spring framework ppt by Rohit malavspring framework ppt by Rohit malav
spring framework ppt by Rohit malavRohit malav
 
Spring framework-tutorial
Spring framework-tutorialSpring framework-tutorial
Spring framework-tutorialvinayiqbusiness
 
Introduction to Spring sec1.pptx
Introduction to Spring sec1.pptxIntroduction to Spring sec1.pptx
Introduction to Spring sec1.pptxNourhanTarek23
 
Spring framework
Spring frameworkSpring framework
Spring frameworkKani Selvam
 
Spring framework Introduction
Spring framework  IntroductionSpring framework  Introduction
Spring framework IntroductionAnuj Singh Rajput
 
Java J2EE Interview Questions Part 2
Java J2EE Interview Questions Part 2Java J2EE Interview Questions Part 2
Java J2EE Interview Questions Part 2javatrainingonline
 
Spring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsSpring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsVirtual Nuggets
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworksMukesh Kumar
 
Spring Fa Qs
Spring Fa QsSpring Fa Qs
Spring Fa Qsjbashask
 
Spring Basics
Spring BasicsSpring Basics
Spring BasicsEmprovise
 

Similaire à Introduction to Spring Framework (20)

Java spring ppt
Java spring pptJava spring ppt
Java spring ppt
 
Spring 2
Spring 2Spring 2
Spring 2
 
Session 43 - Spring - Part 1 - IoC DI Beans
Session 43 - Spring - Part 1 - IoC DI BeansSession 43 - Spring - Part 1 - IoC DI Beans
Session 43 - Spring - Part 1 - IoC DI Beans
 
Spring (1)
Spring (1)Spring (1)
Spring (1)
 
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.
 
spring framework ppt by Rohit malav
spring framework ppt by Rohit malavspring framework ppt by Rohit malav
spring framework ppt by Rohit malav
 
Spring framework-tutorial
Spring framework-tutorialSpring framework-tutorial
Spring framework-tutorial
 
Spring Basics
Spring BasicsSpring Basics
Spring Basics
 
Introduction to Spring sec1.pptx
Introduction to Spring sec1.pptxIntroduction to Spring sec1.pptx
Introduction to Spring sec1.pptx
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Spring framework Introduction
Spring framework  IntroductionSpring framework  Introduction
Spring framework Introduction
 
Java J2EE Interview Question Part 2
Java J2EE Interview Question Part 2Java J2EE Interview Question Part 2
Java J2EE Interview Question Part 2
 
Java J2EE Interview Questions Part 2
Java J2EE Interview Questions Part 2Java J2EE Interview Questions Part 2
Java J2EE Interview Questions Part 2
 
Spring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsSpring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggets
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
 
Spring
SpringSpring
Spring
 
Spring Fa Qs
Spring Fa QsSpring Fa Qs
Spring Fa Qs
 
Spring Basics
Spring BasicsSpring Basics
Spring Basics
 

Dernier

Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 

Dernier (20)

Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 

Introduction to Spring Framework

  • 2. What is a framework ? framework is a universal, reusable software environment that provides particular functionality as part of a larger software platform to facilitate development of software applications, products and solutions. Software frameworks may include support programs compilers code libraries tool sets 2
  • 3. How to separate framework from library …. ❏Inversion Control: In a framework, unlike in libraries the overall program's flow control is not dictated by the caller, but by the framework. ❏default behavior ❏extensibility: can be extended by the user usually by selective overriding or specialized by user code to provide specific functionality. ❏non-modifiable framework code: The framework code, in general, is not supposed to be modified, while accepting user-implemented extensions. 3
  • 4. Spring framework Spring is the most popular application development framework for enterprise Java. open source Java platform initially written by Rod Johnson and was first released under the Apache 2.0 license in June 2003. lightweight when it comes to size and transparency. 4
  • 5. Where to use ? can be used in developing any Java application, but there are extensions for building web applications on top of the Java EE platform. Spring framework targets to make J2EE development easier to use and promote good programming practice by enabling a POJO-based programming model. 5
  • 6. Benefits of spring.. Spring is organized in a modular fashion makes use of technologies like several ORM frameworks, logging frameworks, JEE, Quartz and JDK timers, other view technologies Testing an application written with Spring is simple Spring's web framework is a well-designed web MVC framework provides a convenient API to translate technology-specific exceptions into consistent, unchecked exceptions 6
  • 8. Description of architecture Core Container Core provides the fundamental parts of the framework, including the IoC and Dependency Injection features. Bean provides BeanFactory which is a sophisticated implementation of the factory pattern. Context builds on the solid base provided by the Core and Beans modules and it is a medium to access any objects defined and configured. SpEL module provides a powerful expression language for querying and manipulating an object graph at runtime. 8
  • 9. Data Access/Integration JDBC provides a JDBC-abstraction layer that removes the need to do tedious JDBC related coding. ORM provides integration layers for popular object-relational mapping APIs, including JPA, JDO, Hibernate, and iBatis. OXM provides an abstraction layer that supports Object/XML mapping implementations for JAXB, Castor, XMLBeans, JiBX and XStream. JMS contains features for producing and consuming messages. Transaction supports programmatic and declarative transaction management for classes that implement special interfaces and for all your POJOs. 9
  • 10. Web Web provides basic web-oriented integration features such as multipart file-upload functionality and the initialization of the IoC container using servlet listeners and a web-oriented application context. Web-MVC contains Spring's model-view-controller (MVC) implementation for web applications. Web-Socket provides support for WebSocket-based, two-way communication between client and server in web applications. Web-Portlet provides the MVC implementation to be used in a portlet environment and mirrors the functionality of Web-Servlet module. 10
  • 11. pre-requisites Java Development Kit (JDK) Apache Common Logging API http://commons.apache.org/proper/commons-logging/download_logging.cgi Spring Framework Libraries http://repo.spring.io/release/org/springframework/spring/ 11
  • 12. How to use 1. Create java project 1. Add required libraries 12
  • 13. 3. Create source files. 4. Create Bean configuration file 13
  • 14. 14
  • 15. 15
  • 16. Spring with maven If you are using Maven for dependency management you don’t even need to supply the logging dependency explicitly. To create an application context and use dependency injection to configure an application 16
  • 17. IoC Containers Core of the Spring Framework The container will create the objects, wire them together, configure them, and manage their complete lifecycle from creation till destruction. 17
  • 18. uses dependency injection (DI) to manage the components that make up an application(spring Beans) Spring BeanFactory Container simplest container providing basic support for DI and defined by the org.springframework.beans.factory.BeanFactory interface. The BeanFactory and related interfaces, such as BeanFactoryAware, InitializingBean, DisposableBean, are still present in Spring for the purposes of backward compatibility with the large number of third-party frameworks that integrate with Spring. Spring ApplicationContext Container adds more enterprise-specific functionality such as the ability to resolve textual messages from a properties file and the ability to publish application events to interested event listeners. This container is defined by the org.springframework.context.ApplicationContext interface. 18
  • 19. Benefits of IoC/DI Reduced Dependencies Reduced Dependency Carrying More Reusable Code More Testable Code More Readable Code 19
  • 20. Bean Definition A bean is an object that is instantiated, assembled, and otherwise managed by a Spring IoC container. The bean definition contains the information called configuration metadata which is needed for the container to know the followings How to create a bean Bean's lifecycle details Bean's dependencies 20
  • 21. Spring Configuration Metadata There are three important methods to provide configuration metadata to the Spring Container XML based configuration file. Annotation-based configuration Java-based configuration 21
  • 22. 22
  • 23. Annotation based configuration To describe a bean wiring,move the bean configuration into the component class itself by using annotations on the relevant class, method, or field declaration. Annotation wiring is not turned on in the Spring container by default 23
  • 24. Basic annotations @Required The @Required annotation applies to bean property setter methods. @Autowired The @Autowired annotation can apply to bean property setter methods, non-setter methods, constructor and properties. @Qualifier The @Qualifier annotation along with @Autowired can be used to remove the confusion by specifying which exact bean will be wired. JSR-250 Annotations Spring supports JSR-250 based annotations which include @Resource, @PostConstruct and @PreDestroy annotations. 24
  • 25. Java based configuration Java based configuration option enables you to write most of your Spring configuration without XML but with the help of few Java-based annotations @Configuration class can be used by the Spring IoC container as a source of bean definitions @Bean Annotations return an object that should be registered as a bean in the Spring application context. @Import Annotation 25
  • 26. Dependency Injection The Dependency Injection is a design pattern that removes the dependency of the programs. In such case we provide the information from the external source such as XML file. It makes our code loosely coupled and easier for testing. Spring framework provides two ways to inject dependency By Constructor By Setter method 26
  • 27. In such case, instance of Address class is provided by external source such as XML file either by constructor or setter method. 27
  • 28. Beans auto-wiring Enables you to inject the object dependency implicitly. It internally uses setter or constructor injection. Autowiring can't be used to inject primitive and string values. It works with reference only. 28
  • 29. AOP with Spring Framework Aspect Oriented Programming entails breaking down program logic into distinct parts.(like logging, auditing, declarative transactions, security, and caching etc) Spring AOP module provides interceptors to intercept an application, when a method is executed, you can add extra functionality before or after the method execution. 29
  • 31. Other Spring projects Spring Cloud Spring Data Spring Security Spring Social Spring Mobile Spring Session Spring Shell 31