SlideShare uma empresa Scribd logo
Spring Framework
Sonal Poddar
sonalpoddar@hotmail.com
Content
• What is Spring Framework?
• Key features of Spring Framework
 Spring Modules
 Dependency Injection and Inversion of Control
 Spring AOP
• Spring Environment Setup
• Quick Steps to Develop Spring Application
• Spring Hello World Example
• Setter Injection v/s Constructor Injection
• Spring Autowiring
What is Spring Framework?
• Spring is a light weight and open source framework created
by Rod Johnson in 2003
• It is a framework of frameworks
• Spring framework is said to be a non-invasive.
• Spring Framework made J2EE application development little
easier, by introducing POJO model
• Spring having so much of demand because of the following 3
reasons….
 Simplicity
 Testability
 Loose Coupling
Key features of Spring Framework
Spring Modules
 Test
 Core Container
 AOP
 Aspects
 Instrumentation
 Data Access/ Integration
 Web (MVC / Remoting)
Spring Core Module – Loose Coupling
Tight Coupling
When an object creates the object to be used, then it is a tight coupling
situation.
As the main object creates the object itself, this object can not be changed
from outside world easily marked it as tightly coupled objects.
When an object gets the object to be used from the outside, then it is a loose
coupling situation.
As the main object is merely using the object, this object can be changed
from the outside world easily marked it as loosely coupled objects.
Loose Coupling
IoC and Dependency Injection
What is Inversion of Control ?
Inversion of Control is a principle in software engineering by which the control
of objects or portions of a program is transferred to a container or framework.
It's most often used in the context of object-oriented programming.
Inversion of Control can be achieved through various mechanisms such as:
Strategy design pattern, Service Locator pattern, Factory pattern, and
Dependency Injection (DI).
IoC and Dependency Injection (cont.)
What is Spring IoC Container ?
• An IoC container is a common characteristic of frameworks that implement
IoC.
• In the Spring framework, the IoC container is represented by the interface
ApplicationContext.
• The Spring container is responsible for instantiating, configuring and
assembling objects known as beans, as well as managing their lifecycle.
• The Spring framework provides several implementations of the
ApplicationContext interface — ClassPathXmlApplicationContext and
FileSystemXmlApplicationContext for standalone applications, and
WebApplicationContext for web applications.
• Here's one way to manually instantiate a container:
IoC and Dependency Injection (cont.)
Spring IoC Container Overview
• The configuration metadata can be represented either by;
 XML
 Java Annotations
IoC and Dependency Injection (cont.)
What is Dependency Injection?
Dependency injection is a pattern through which to implement IoC, where the
control being inverted is the setting of object's dependencies.
The act of connecting objects with other objects, or “injecting” objects into
other objects, is done by an assembler rather than by the objects themselves.
Traditional Programming Using DI
IoC and Dependency Injection (cont.)
Types of Dependency Injection
Spring framework provides two ways to inject dependency:-
 By Setter method
• In this type of injection, the spring container uses setter method in the
dependent class for injecting its dependencies (primitive values or any).
• Spring container knows whether to perform setter or constructor
injection by reading the information from an external file called spring
configuration file
• In spring config xml, we need to inform to the spring IOC container about
setter injection by using <property/>
 By Constructor
• In this type of injection, spring container uses constructor of the bean
class for assigning the dependencies.
• In spring config xml, we need to inform to the spring IOC container about
constructor injection by using <constructor –arg/>
Spring AOP
Introduction
• Aspect Oriented Programming (AOP) compliments OOPs in the sense that
it also provides modularity. But the key unit of modularity is aspect than
class.
• AOP breaks the program logic into distinct parts (called concerns). It is
used to increase modularity by cross-cutting concerns.
• A cross-cutting concern is a concern that can affect the whole application
and should be centralized in one location in code as possible, such as
transaction management, authentication, logging, security etc.
• It provides the pluggable way to dynamically add the additional concern
before, after or around the actual logic.
• AOP terminologies are Join point, Advice, Pointcut, Introduction,
Target Object, Aspect, Interceptor, AOP Proxy, Weaving
Spring Environment Setup
 Step 1 - Setup Java Development Kit (JDK)
You can download the latest version of SDK from Oracle's Java site
https://www.oracle.com/java/technologies/javase-downloads.html
 Step 2 - Install Apache Common Logging API
You can download the latest version of Apache Commons Logging API from
https://commons.apache.org/logging/
 Step 3 - Setup Eclipse IDE
To install Eclipse IDE, download the latest Eclipse binaries from
https://www.eclipse.org/downloads/
 Step 4 - Setup Spring Framework Libraries
Download the latest version of Spring framework libraries from
https://repo.spring.io/release/org/springframework/spring
Quick Steps to Develop Spring Application
• Spring environment starts by loading spring configuration xml file into Resource
Interface object.
• Actually this configuration file contains all bean configurations about our
application [ something like struts.xml in Struts 2 ]
• ClassPathResource is the implementation class of the Resource interface.
• Spring IOC container is called BeanFactory and this container is responsible for
creating the bean objects and for injecting it’s dependencies throughout our
applications.
• The XmlBeanFactory is the implementation class of the BeanFactory. There are
many methods in the BeanFactory interface. One method is getBean(), which
returns the object of the associated class.
• Syntax
Resource res = new ClassPathResource(“Our Config xml file name”);
BeanFactory factory = new XmlBeanFactory(res);
Spring Hello World Example
Demo in Eclipse
Using Setter Injection & Constructor Injection with Primitive Values
Setter Injection v/s Constructor Injection
 Partial dependency: can be injected using setter injection but it is not
possible by constructor. Suppose there are 3 properties in a class, having 3 arg
constructor and setters methods. In such case, if you want to pass information
for only one property, it is possible by setter method only.
 Overriding: Setter injection overrides the constructor injection. If we use
both constructor and setter injection, IOC container will use the setter
injection.
 Changes: We can easily change the value by setter injection. It doesn't
create a new bean instance always like constructor. So setter injection is
flexible than constructor injection.
Spring Autowiring
 Autowiring feature of spring framework enables you to inject the object
dependency implicitly.
 It internally uses setter or constructor injection.
 Autowiring can't be used to inject primitive values. It works with
reference only.
Autowiring Modes
• byName
• byType
• constructor
• autoDetect
• none
Thank You!

Mais conteúdo relacionado

Mais procurados

Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Serhat Can
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
Mehul Jariwala
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
ASG
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
tola99
 
Spring Boot
Spring BootSpring Boot
Spring Boot
HongSeong Jeon
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
Jonathan Holloway
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
NexThoughts Technologies
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
nomykk
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
Muthuselvam RS
 
Java spring framework
Java spring frameworkJava spring framework
Java spring framework
Rajiv Gupta
 
Connecting Connect with Spring Boot
Connecting Connect with Spring BootConnecting Connect with Spring Boot
Connecting Connect with Spring Boot
Vincent Kok
 
Spring Boot
Spring BootSpring Boot
Spring Boot
koppenolski
 
Spring andspringboot training
Spring andspringboot trainingSpring andspringboot training
Spring andspringboot training
Mallikarjuna G D
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
Pravin Pundge
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
Alex Movila
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jaran Flaath
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
Trey Howard
 
Xke spring boot
Xke spring bootXke spring boot
Xke spring boot
sourabh aggarwal
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
Santosh Kumar Kar
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
Dzmitry Naskou
 

Mais procurados (20)

Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
 
Java spring framework
Java spring frameworkJava spring framework
Java spring framework
 
Connecting Connect with Spring Boot
Connecting Connect with Spring BootConnecting Connect with Spring Boot
Connecting Connect with Spring Boot
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring andspringboot training
Spring andspringboot trainingSpring andspringboot training
Spring andspringboot training
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Xke spring boot
Xke spring bootXke spring boot
Xke spring boot
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 

Semelhante a Spring framework

Introduction to Spring
Introduction to SpringIntroduction to Spring
Introduction to Spring
Sujit Kumar
 
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
 
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
PawanMM
 
Spring session
Spring sessionSpring session
Spring session
Gamal Shaban
 
Introduction to Spring sec1.pptx
Introduction to Spring sec1.pptxIntroduction to Spring sec1.pptx
Introduction to Spring sec1.pptx
NourhanTarek23
 
Spring Basics
Spring BasicsSpring Basics
Spring framework
Spring frameworkSpring framework
Spring framework
Kani Selvam
 
Spring framework
Spring frameworkSpring framework
Spring framework
Shivi Kashyap
 
Spring framework
Spring frameworkSpring framework
Spring framework
Rajkumar Singh
 
Spring IOC and DAO
Spring IOC and DAOSpring IOC and DAO
Spring IOC and DAO
AnushaNaidu
 
Brownbag001 spring ioc from 2012
Brownbag001 spring ioc from 2012Brownbag001 spring ioc from 2012
Brownbag001 spring ioc from 2012
Timothy Spann
 
Spring (1)
Spring (1)Spring (1)
Spring (1)
Aneega
 
스프링 프레임워크
스프링 프레임워크스프링 프레임워크
스프링 프레임워크
Yoonki Chang
 
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of ControlJava Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Arjun Thakur
 
Springs_Training
Springs_TrainingSprings_Training
Springs_Training
KAMALA KOLLURI
 
Java spring ppt
Java spring pptJava spring ppt
Java spring ppt
natashasweety7
 
Spring framework
Spring frameworkSpring framework
Spring framework
vietduc17
 
Screenshot from 2024-05-28 16-46-45 (30 files merged).ppt
Screenshot from 2024-05-28 16-46-45 (30 files merged).pptScreenshot from 2024-05-28 16-46-45 (30 files merged).ppt
Screenshot from 2024-05-28 16-46-45 (30 files merged).ppt
imjdabhinawpandey
 
Spring Framework Presantation Part 1-Core
Spring Framework Presantation Part 1-CoreSpring Framework Presantation Part 1-Core
Spring Framework Presantation Part 1-Core
Donald Lika
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
Mohit Gupta
 

Semelhante a Spring framework (20)

Introduction to Spring
Introduction to SpringIntroduction to Spring
Introduction to Spring
 
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
 
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 session
Spring sessionSpring session
Spring session
 
Introduction to Spring sec1.pptx
Introduction to Spring sec1.pptxIntroduction to Spring sec1.pptx
Introduction to Spring sec1.pptx
 
Spring Basics
Spring BasicsSpring Basics
Spring Basics
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Spring IOC and DAO
Spring IOC and DAOSpring IOC and DAO
Spring IOC and DAO
 
Brownbag001 spring ioc from 2012
Brownbag001 spring ioc from 2012Brownbag001 spring ioc from 2012
Brownbag001 spring ioc from 2012
 
Spring (1)
Spring (1)Spring (1)
Spring (1)
 
스프링 프레임워크
스프링 프레임워크스프링 프레임워크
스프링 프레임워크
 
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
 
Springs_Training
Springs_TrainingSprings_Training
Springs_Training
 
Java spring ppt
Java spring pptJava spring ppt
Java spring ppt
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Screenshot from 2024-05-28 16-46-45 (30 files merged).ppt
Screenshot from 2024-05-28 16-46-45 (30 files merged).pptScreenshot from 2024-05-28 16-46-45 (30 files merged).ppt
Screenshot from 2024-05-28 16-46-45 (30 files merged).ppt
 
Spring Framework Presantation Part 1-Core
Spring Framework Presantation Part 1-CoreSpring Framework Presantation Part 1-Core
Spring Framework Presantation Part 1-Core
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
 

Último

Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
jpupo2018
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 

Último (20)

Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 

Spring framework

  • 2. Content • What is Spring Framework? • Key features of Spring Framework  Spring Modules  Dependency Injection and Inversion of Control  Spring AOP • Spring Environment Setup • Quick Steps to Develop Spring Application • Spring Hello World Example • Setter Injection v/s Constructor Injection • Spring Autowiring
  • 3. What is Spring Framework? • Spring is a light weight and open source framework created by Rod Johnson in 2003 • It is a framework of frameworks • Spring framework is said to be a non-invasive. • Spring Framework made J2EE application development little easier, by introducing POJO model • Spring having so much of demand because of the following 3 reasons….  Simplicity  Testability  Loose Coupling
  • 4. Key features of Spring Framework Spring Modules  Test  Core Container  AOP  Aspects  Instrumentation  Data Access/ Integration  Web (MVC / Remoting)
  • 5. Spring Core Module – Loose Coupling Tight Coupling When an object creates the object to be used, then it is a tight coupling situation. As the main object creates the object itself, this object can not be changed from outside world easily marked it as tightly coupled objects. When an object gets the object to be used from the outside, then it is a loose coupling situation. As the main object is merely using the object, this object can be changed from the outside world easily marked it as loosely coupled objects. Loose Coupling
  • 6. IoC and Dependency Injection What is Inversion of Control ? Inversion of Control is a principle in software engineering by which the control of objects or portions of a program is transferred to a container or framework. It's most often used in the context of object-oriented programming. Inversion of Control can be achieved through various mechanisms such as: Strategy design pattern, Service Locator pattern, Factory pattern, and Dependency Injection (DI).
  • 7. IoC and Dependency Injection (cont.) What is Spring IoC Container ? • An IoC container is a common characteristic of frameworks that implement IoC. • In the Spring framework, the IoC container is represented by the interface ApplicationContext. • The Spring container is responsible for instantiating, configuring and assembling objects known as beans, as well as managing their lifecycle. • The Spring framework provides several implementations of the ApplicationContext interface — ClassPathXmlApplicationContext and FileSystemXmlApplicationContext for standalone applications, and WebApplicationContext for web applications. • Here's one way to manually instantiate a container:
  • 8. IoC and Dependency Injection (cont.) Spring IoC Container Overview • The configuration metadata can be represented either by;  XML  Java Annotations
  • 9. IoC and Dependency Injection (cont.) What is Dependency Injection? Dependency injection is a pattern through which to implement IoC, where the control being inverted is the setting of object's dependencies. The act of connecting objects with other objects, or “injecting” objects into other objects, is done by an assembler rather than by the objects themselves. Traditional Programming Using DI
  • 10. IoC and Dependency Injection (cont.) Types of Dependency Injection Spring framework provides two ways to inject dependency:-  By Setter method • In this type of injection, the spring container uses setter method in the dependent class for injecting its dependencies (primitive values or any). • Spring container knows whether to perform setter or constructor injection by reading the information from an external file called spring configuration file • In spring config xml, we need to inform to the spring IOC container about setter injection by using <property/>  By Constructor • In this type of injection, spring container uses constructor of the bean class for assigning the dependencies. • In spring config xml, we need to inform to the spring IOC container about constructor injection by using <constructor –arg/>
  • 11. Spring AOP Introduction • Aspect Oriented Programming (AOP) compliments OOPs in the sense that it also provides modularity. But the key unit of modularity is aspect than class. • AOP breaks the program logic into distinct parts (called concerns). It is used to increase modularity by cross-cutting concerns. • A cross-cutting concern is a concern that can affect the whole application and should be centralized in one location in code as possible, such as transaction management, authentication, logging, security etc. • It provides the pluggable way to dynamically add the additional concern before, after or around the actual logic. • AOP terminologies are Join point, Advice, Pointcut, Introduction, Target Object, Aspect, Interceptor, AOP Proxy, Weaving
  • 12. Spring Environment Setup  Step 1 - Setup Java Development Kit (JDK) You can download the latest version of SDK from Oracle's Java site https://www.oracle.com/java/technologies/javase-downloads.html  Step 2 - Install Apache Common Logging API You can download the latest version of Apache Commons Logging API from https://commons.apache.org/logging/  Step 3 - Setup Eclipse IDE To install Eclipse IDE, download the latest Eclipse binaries from https://www.eclipse.org/downloads/  Step 4 - Setup Spring Framework Libraries Download the latest version of Spring framework libraries from https://repo.spring.io/release/org/springframework/spring
  • 13. Quick Steps to Develop Spring Application • Spring environment starts by loading spring configuration xml file into Resource Interface object. • Actually this configuration file contains all bean configurations about our application [ something like struts.xml in Struts 2 ] • ClassPathResource is the implementation class of the Resource interface. • Spring IOC container is called BeanFactory and this container is responsible for creating the bean objects and for injecting it’s dependencies throughout our applications. • The XmlBeanFactory is the implementation class of the BeanFactory. There are many methods in the BeanFactory interface. One method is getBean(), which returns the object of the associated class. • Syntax Resource res = new ClassPathResource(“Our Config xml file name”); BeanFactory factory = new XmlBeanFactory(res);
  • 14. Spring Hello World Example Demo in Eclipse Using Setter Injection & Constructor Injection with Primitive Values
  • 15. Setter Injection v/s Constructor Injection  Partial dependency: can be injected using setter injection but it is not possible by constructor. Suppose there are 3 properties in a class, having 3 arg constructor and setters methods. In such case, if you want to pass information for only one property, it is possible by setter method only.  Overriding: Setter injection overrides the constructor injection. If we use both constructor and setter injection, IOC container will use the setter injection.  Changes: We can easily change the value by setter injection. It doesn't create a new bean instance always like constructor. So setter injection is flexible than constructor injection.
  • 16. Spring Autowiring  Autowiring feature of spring framework enables you to inject the object dependency implicitly.  It internally uses setter or constructor injection.  Autowiring can't be used to inject primitive values. It works with reference only. Autowiring Modes • byName • byType • constructor • autoDetect • none