SlideShare a Scribd company logo
Introduction to
Spring Framework
CSE424: Aspect and Service Oriented Software Systems
Content :
 What is Spring Framework?
 Key Features of Spring Framework
 Advantages of Spring Framework.
Dependency Injection and Inversion of Control
 Aspect oriented Programming
 Spring Modules
 Spring Security
 Spring Testing
What is Spring Framework ?
 Spring is the most popular application development framework
for enterprise java.
 Open source java platform since 2003.
 Spring support all major application servers and JEE Standards.
 Spring handlers the infrastructure so you can focus on
application.
Dependency Injection
Introduction to Concept
 The technology that actually defines spring (Heart of Spring).
 Dependency Injection helps us to keep our classes or independent as possible.
Increase reuse by applying low coupling.
Easy Testing.
More Understandable.
Dependency Injection
Introduction to Concept
An injection is the passing of dependency (a service) to a dependent
object (a client).
Passing the service to the client, rather than allowing a client to build
or find the service, is the fundamental requirement of the pattern.
“Dependency Injection is a pattern where the container passes objects by name to
other objects, via either constructors, properties or factory methods.”
Dependency Injection
Relationship between DI and Inversion of Control
In software engineering, inversion of Control (IoC) describes a design in
which custom-written portions if a computer program receive the flow of
control from a generic reusable library.
The Inversion of Control (Ioc) is a general concepts, and it can be expressed in many
different ways and dependency Injection is merely one concrete example of
Inversion of Control.
Dependency Injection
Ioc Container
 The spring container (IoC Container) is at the 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.
Dependency Injection
Ioc Container
 The Container gets its instructions on
what objects to instantiate, configure,
and assemble by reading configuration
metadata provided.
 The configuration metadata can be
represented either by;
XML,
Java annotations,
Java Code.
Dependency Injection
Code Example
Dependency Injection
Bean Scopes
Scope Description
Singleton (Default) Scopes a single bean definition to a single object instance per spring
IoC Container.
Prototype Scopes a single bean definition to any number of objects instances.
Spring ApplicationContext
 A Spring ApplicationContext allows you to get access
to the objects that are configured in a BeanFactory in
a framework manner.
 ApplicationContext extends BeanFactory
 Adds services such as international messaging capabilities.
 Add the ability to load file resources in a generic fashion.
 Several ways to configure a context:
 XMLWebApplicationContext – Configuration for a web
application.
 ClassPathXMLApplicationContext – standalone XML
application context
 FileSystemXmlApplicationContext
Aspects Oriented Programming (Aop)
Spring AoP
Spring AoP module provides interceptors to intercept an application, for example,
when a method is executed, you can add extra functionality before or after the
method execution.
Spring AoP's approach to AoP differs from that of most AoP Frameworks. The aim is to
provide a close integration between AoP implementation and IoC, not to provide the
most complete AoP implementation.
Spring Framework’s AoP functionality is normally in conjunction with the Spring IoC
Container. Aspects are configured using normal bean definition syntax.
Spring Modules
 The Spring Framework consists
of features Organizes into about
20 modules.
 These modules are grouped into
Cross containers, Data
Access/Integration, Web,
AoP(Aspect Oriented
Programming), Instrumentation,
and Test.
Spring Modules
The building blocks described
previously make Spring a logical
choice in many scenarios, from
applets to full-fledged enterprise
applications that use Springs
transaction management
functionality and web framework
integration.
Spring Modules
Spring Projects
Spring XD
Spring Data
Spring Integration
Spring Batch
Spring Security
Spring Cloud
Spring AMQD
Spring Grails
Spring Mobile
Spring Social
Spring for Android
Spring Web Flow
Spring LDAP
Spring Groovy
Spring Hateoas
Spring Security QAuth
Spring Security
Spring Security is a framework that focuses on providing both
Authentication and Authorization to Java Applications.
Features:
Comprehensive and extensible support for both Authentication and
Authorization.
Protection against attacks like session fixation, clickjacking,
cross site request forgery, etc.
Servlet API Integration.
Optional integration with Spring web MVC.
Spring Test
 Spring Test Framework Supports:
Unit testing with mock object.
Easy unit testing for controllers.
IoC Container to create dependencies for Integration Testing.
Transaction management for Integration Testing.
Third party frameworks like JUnit, TestNG, Mockito.
Advantages using Spring Framework
Open Source.
Lightweight and fast.
Modular structure.
Low coupling thanks to Dependency Injection.
Reusable Software.
Stable and lots of resource.
AoP Support.
Projector that make our life easier like Spring Security.
Setting up your environment
What is Maven?
 A Java project management and integration build tool.
 Based on the concept of XML Project Object Model (POM).
 Originally developed for building Turbine.
 A small core with numerous plugins (in Jelly).
Maven Architecture Overview
Build System
Local
Repo
Remote
Repo
maven
project.xml (pom)
maven.xml (goals) http
Site
Maven Artifact Repository
The Most Important Feature
 Remote Repository
…
<dependencies>
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.5.1</version>
<type>jar</type>
</dependency>
…
</dependencies>
…
${mave.repo.remote}/<groupId>/<type>s/<artifactId>-<version>.<type>
- repository
- […]
- xalan
- jars
- xalan-2.5.0.jar
- xalan-2.5.1.jar
- […]
- […]
Getting started
 Download Eclipse IDE
 Open a new Maven project
Getting started
 Download Eclipse IDE
 Open a new Maven project
Getting started
 Download Eclipse IDE
 Open a new Maven project
 After pressing finish, you download of
the repositories will start (it may take
some minutes if the internet speed is
slow)
Getting started
 This is the main project and the most important file is pom.xml
Getting started
 This is the main project and the most important file is pom.xml
Getting started
 POM.xml file
In this part, we are going to
download the spring
framework
Getting started
 Setting the dependencies within the pom.xml file
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>6.0.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>6.0.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>6.0.5</version>
</dependency>
Getting started
 To start our first Aspect project we need:
1. Dependent class files
2. A new xml file to remove the dependency
 Bean dependencies:
 In a new xml file add the beans
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/co
ntext"
xsi:schemaLocation="http://www.springframework.org/sche
ma/beans
http://www.springframework.org/schema/beans/spring-
beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-
context.xsd">

More Related Content

Similar to Introduction to Spring sec1.pptx

Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Dineesha Suraweera
 
Java J2EE Interview Question Part 2
Java J2EE Interview Question Part 2Java J2EE Interview Question Part 2
Java J2EE Interview Question Part 2
Mindsmapped Consulting
 
Java J2EE Interview Questions Part 2
Java J2EE Interview Questions Part 2Java J2EE Interview Questions Part 2
Java J2EE Interview Questions Part 2
javatrainingonline
 
Java spring ppt
Java spring pptJava spring ppt
Java spring ppt
natashasweety7
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
NexThoughts Technologies
 
Spring session
Spring sessionSpring session
Spring session
Gamal Shaban
 
Spring framework
Spring frameworkSpring framework
Spring framework
Sonal Poddar
 
How Spring Framework Really Works?
How Spring Framework Really Works?How Spring Framework Really Works?
How Spring Framework Really Works?
NexSoftsys
 
The Power of Enterprise Java Frameworks
The Power of Enterprise Java FrameworksThe Power of Enterprise Java Frameworks
The Power of Enterprise Java Frameworks
Clarence Ho
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
Muthuselvam RS
 
Spring Basics
Spring BasicsSpring Basics
Spring Basics
Emprovise
 
Learn Spring Boot With Bisky - Intoduction
Learn Spring Boot With Bisky - IntoductionLearn Spring Boot With Bisky - Intoduction
Learn Spring Boot With Bisky - Intoduction
MarshallChabaga
 
Spring ppt
Spring pptSpring ppt
Spring ppt
Mumbai Academisc
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
tola99
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
Mehul Jariwala
 

Similar to Introduction to Spring sec1.pptx (20)

Spring survey
Spring surveySpring survey
Spring survey
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
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
 
Java spring ppt
Java spring pptJava spring ppt
Java spring ppt
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
Spring session
Spring sessionSpring session
Spring session
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
How Spring Framework Really Works?
How Spring Framework Really Works?How Spring Framework Really Works?
How Spring Framework Really Works?
 
The Power of Enterprise Java Frameworks
The Power of Enterprise Java FrameworksThe Power of Enterprise Java Frameworks
The Power of Enterprise Java Frameworks
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
 
Spring
SpringSpring
Spring
 
Spring Framework Rohit
Spring Framework RohitSpring Framework Rohit
Spring Framework Rohit
 
Spring Basics
Spring BasicsSpring Basics
Spring Basics
 
Learn Spring Boot With Bisky - Intoduction
Learn Spring Boot With Bisky - IntoductionLearn Spring Boot With Bisky - Intoduction
Learn Spring Boot With Bisky - Intoduction
 
Spring ppt
Spring pptSpring ppt
Spring ppt
 
Spring notes
Spring notesSpring notes
Spring notes
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
 

More from NourhanTarek23

CSE031.Lecture_05.Networks.pdf
CSE031.Lecture_05.Networks.pdfCSE031.Lecture_05.Networks.pdf
CSE031.Lecture_05.Networks.pdf
NourhanTarek23
 
CSE031.Lecture_07-FlowCharts_Pseudocode .Part_II.pdf
CSE031.Lecture_07-FlowCharts_Pseudocode .Part_II.pdfCSE031.Lecture_07-FlowCharts_Pseudocode .Part_II.pdf
CSE031.Lecture_07-FlowCharts_Pseudocode .Part_II.pdf
NourhanTarek23
 
CSE031.Lecture_11-Operating_Systems.Part_I.pptx
CSE031.Lecture_11-Operating_Systems.Part_I.pptxCSE031.Lecture_11-Operating_Systems.Part_I.pptx
CSE031.Lecture_11-Operating_Systems.Part_I.pptx
NourhanTarek23
 
Lect02 Introducing Programming.ppt
Lect02 Introducing Programming.pptLect02 Introducing Programming.ppt
Lect02 Introducing Programming.ppt
NourhanTarek23
 
Lect01 Introduction of Visual Basic.ppt
Lect01 Introduction of Visual Basic.pptLect01 Introduction of Visual Basic.ppt
Lect01 Introduction of Visual Basic.ppt
NourhanTarek23
 
Software engineering.pptx
Software engineering.pptxSoftware engineering.pptx
Software engineering.pptx
NourhanTarek23
 
Lect01 Computers Impact on Our lives IOT and Big Data Era.pptx
Lect01 Computers Impact on Our lives  IOT and Big Data Era.pptxLect01 Computers Impact on Our lives  IOT and Big Data Era.pptx
Lect01 Computers Impact on Our lives IOT and Big Data Era.pptx
NourhanTarek23
 
Lab 7 - Bash Script.pptx
Lab 7 - Bash Script.pptxLab 7 - Bash Script.pptx
Lab 7 - Bash Script.pptx
NourhanTarek23
 
section5.pptx
section5.pptxsection5.pptx
section5.pptx
NourhanTarek23
 
Introduction to computer.pptx
Introduction to computer.pptxIntroduction to computer.pptx
Introduction to computer.pptx
NourhanTarek23
 
AOP sec3.pptx
AOP sec3.pptxAOP sec3.pptx
AOP sec3.pptx
NourhanTarek23
 
Introduction to Spring sec2.pptx
Introduction to Spring sec2.pptxIntroduction to Spring sec2.pptx
Introduction to Spring sec2.pptx
NourhanTarek23
 
QoS.pptx
QoS.pptxQoS.pptx
QoS.pptx
NourhanTarek23
 
’mobile ip.pptx
’mobile ip.pptx’mobile ip.pptx
’mobile ip.pptx
NourhanTarek23
 
Problem set 3-solution.pptx
Problem set 3-solution.pptxProblem set 3-solution.pptx
Problem set 3-solution.pptx
NourhanTarek23
 

More from NourhanTarek23 (15)

CSE031.Lecture_05.Networks.pdf
CSE031.Lecture_05.Networks.pdfCSE031.Lecture_05.Networks.pdf
CSE031.Lecture_05.Networks.pdf
 
CSE031.Lecture_07-FlowCharts_Pseudocode .Part_II.pdf
CSE031.Lecture_07-FlowCharts_Pseudocode .Part_II.pdfCSE031.Lecture_07-FlowCharts_Pseudocode .Part_II.pdf
CSE031.Lecture_07-FlowCharts_Pseudocode .Part_II.pdf
 
CSE031.Lecture_11-Operating_Systems.Part_I.pptx
CSE031.Lecture_11-Operating_Systems.Part_I.pptxCSE031.Lecture_11-Operating_Systems.Part_I.pptx
CSE031.Lecture_11-Operating_Systems.Part_I.pptx
 
Lect02 Introducing Programming.ppt
Lect02 Introducing Programming.pptLect02 Introducing Programming.ppt
Lect02 Introducing Programming.ppt
 
Lect01 Introduction of Visual Basic.ppt
Lect01 Introduction of Visual Basic.pptLect01 Introduction of Visual Basic.ppt
Lect01 Introduction of Visual Basic.ppt
 
Software engineering.pptx
Software engineering.pptxSoftware engineering.pptx
Software engineering.pptx
 
Lect01 Computers Impact on Our lives IOT and Big Data Era.pptx
Lect01 Computers Impact on Our lives  IOT and Big Data Era.pptxLect01 Computers Impact on Our lives  IOT and Big Data Era.pptx
Lect01 Computers Impact on Our lives IOT and Big Data Era.pptx
 
Lab 7 - Bash Script.pptx
Lab 7 - Bash Script.pptxLab 7 - Bash Script.pptx
Lab 7 - Bash Script.pptx
 
section5.pptx
section5.pptxsection5.pptx
section5.pptx
 
Introduction to computer.pptx
Introduction to computer.pptxIntroduction to computer.pptx
Introduction to computer.pptx
 
AOP sec3.pptx
AOP sec3.pptxAOP sec3.pptx
AOP sec3.pptx
 
Introduction to Spring sec2.pptx
Introduction to Spring sec2.pptxIntroduction to Spring sec2.pptx
Introduction to Spring sec2.pptx
 
QoS.pptx
QoS.pptxQoS.pptx
QoS.pptx
 
’mobile ip.pptx
’mobile ip.pptx’mobile ip.pptx
’mobile ip.pptx
 
Problem set 3-solution.pptx
Problem set 3-solution.pptxProblem set 3-solution.pptx
Problem set 3-solution.pptx
 

Recently uploaded

Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 

Recently uploaded (20)

Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 

Introduction to Spring sec1.pptx

  • 1. Introduction to Spring Framework CSE424: Aspect and Service Oriented Software Systems
  • 2. Content :  What is Spring Framework?  Key Features of Spring Framework  Advantages of Spring Framework. Dependency Injection and Inversion of Control  Aspect oriented Programming  Spring Modules  Spring Security  Spring Testing
  • 3. What is Spring Framework ?  Spring is the most popular application development framework for enterprise java.  Open source java platform since 2003.  Spring support all major application servers and JEE Standards.  Spring handlers the infrastructure so you can focus on application.
  • 4. Dependency Injection Introduction to Concept  The technology that actually defines spring (Heart of Spring).  Dependency Injection helps us to keep our classes or independent as possible. Increase reuse by applying low coupling. Easy Testing. More Understandable.
  • 5. Dependency Injection Introduction to Concept An injection is the passing of dependency (a service) to a dependent object (a client). Passing the service to the client, rather than allowing a client to build or find the service, is the fundamental requirement of the pattern. “Dependency Injection is a pattern where the container passes objects by name to other objects, via either constructors, properties or factory methods.”
  • 6. Dependency Injection Relationship between DI and Inversion of Control In software engineering, inversion of Control (IoC) describes a design in which custom-written portions if a computer program receive the flow of control from a generic reusable library. The Inversion of Control (Ioc) is a general concepts, and it can be expressed in many different ways and dependency Injection is merely one concrete example of Inversion of Control.
  • 7. Dependency Injection Ioc Container  The spring container (IoC Container) is at the 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.
  • 8. Dependency Injection Ioc Container  The Container gets its instructions on what objects to instantiate, configure, and assemble by reading configuration metadata provided.  The configuration metadata can be represented either by; XML, Java annotations, Java Code.
  • 10. Dependency Injection Bean Scopes Scope Description Singleton (Default) Scopes a single bean definition to a single object instance per spring IoC Container. Prototype Scopes a single bean definition to any number of objects instances.
  • 11. Spring ApplicationContext  A Spring ApplicationContext allows you to get access to the objects that are configured in a BeanFactory in a framework manner.  ApplicationContext extends BeanFactory  Adds services such as international messaging capabilities.  Add the ability to load file resources in a generic fashion.  Several ways to configure a context:  XMLWebApplicationContext – Configuration for a web application.  ClassPathXMLApplicationContext – standalone XML application context  FileSystemXmlApplicationContext
  • 12. Aspects Oriented Programming (Aop) Spring AoP Spring AoP module provides interceptors to intercept an application, for example, when a method is executed, you can add extra functionality before or after the method execution. Spring AoP's approach to AoP differs from that of most AoP Frameworks. The aim is to provide a close integration between AoP implementation and IoC, not to provide the most complete AoP implementation. Spring Framework’s AoP functionality is normally in conjunction with the Spring IoC Container. Aspects are configured using normal bean definition syntax.
  • 13. Spring Modules  The Spring Framework consists of features Organizes into about 20 modules.  These modules are grouped into Cross containers, Data Access/Integration, Web, AoP(Aspect Oriented Programming), Instrumentation, and Test.
  • 14. Spring Modules The building blocks described previously make Spring a logical choice in many scenarios, from applets to full-fledged enterprise applications that use Springs transaction management functionality and web framework integration.
  • 15. Spring Modules Spring Projects Spring XD Spring Data Spring Integration Spring Batch Spring Security Spring Cloud Spring AMQD Spring Grails Spring Mobile Spring Social Spring for Android Spring Web Flow Spring LDAP Spring Groovy Spring Hateoas Spring Security QAuth
  • 16. Spring Security Spring Security is a framework that focuses on providing both Authentication and Authorization to Java Applications. Features: Comprehensive and extensible support for both Authentication and Authorization. Protection against attacks like session fixation, clickjacking, cross site request forgery, etc. Servlet API Integration. Optional integration with Spring web MVC.
  • 17. Spring Test  Spring Test Framework Supports: Unit testing with mock object. Easy unit testing for controllers. IoC Container to create dependencies for Integration Testing. Transaction management for Integration Testing. Third party frameworks like JUnit, TestNG, Mockito.
  • 18. Advantages using Spring Framework Open Source. Lightweight and fast. Modular structure. Low coupling thanks to Dependency Injection. Reusable Software. Stable and lots of resource. AoP Support. Projector that make our life easier like Spring Security.
  • 19. Setting up your environment What is Maven?  A Java project management and integration build tool.  Based on the concept of XML Project Object Model (POM).  Originally developed for building Turbine.  A small core with numerous plugins (in Jelly).
  • 20. Maven Architecture Overview Build System Local Repo Remote Repo maven project.xml (pom) maven.xml (goals) http Site
  • 21. Maven Artifact Repository The Most Important Feature  Remote Repository … <dependencies> <dependency> <groupId>xalan</groupId> <artifactId>xalan</artifactId> <version>2.5.1</version> <type>jar</type> </dependency> … </dependencies> … ${mave.repo.remote}/<groupId>/<type>s/<artifactId>-<version>.<type> - repository - […] - xalan - jars - xalan-2.5.0.jar - xalan-2.5.1.jar - […] - […]
  • 22. Getting started  Download Eclipse IDE  Open a new Maven project
  • 23. Getting started  Download Eclipse IDE  Open a new Maven project
  • 24. Getting started  Download Eclipse IDE  Open a new Maven project  After pressing finish, you download of the repositories will start (it may take some minutes if the internet speed is slow)
  • 25. Getting started  This is the main project and the most important file is pom.xml
  • 26. Getting started  This is the main project and the most important file is pom.xml
  • 27. Getting started  POM.xml file In this part, we are going to download the spring framework
  • 28. Getting started  Setting the dependencies within the pom.xml file <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>6.0.5</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>6.0.5</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>6.0.5</version> </dependency>
  • 29. Getting started  To start our first Aspect project we need: 1. Dependent class files 2. A new xml file to remove the dependency  Bean dependencies:  In a new xml file add the beans <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/co ntext" xsi:schemaLocation="http://www.springframework.org/sche ma/beans http://www.springframework.org/schema/beans/spring- beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring- context.xsd">