SlideShare uma empresa Scribd logo
Spring Framework
• Spring is a lightweight framework. It can be thought of
as a framework of frameworks because it provides
support to various frameworks such as Struts,
Hibernate, Tapestry, EJB, JSF etc. The framework, in
broader sense, can be defined as a structure where we
find solution of the various technical problems.
• The Spring framework comprises several modules such
as IOC, AOP, DAO, Context, ORM, WEB MVC etc. We
will learn these modules in next page. Let's understand
the IOC and Dependency Injection first.
Inversion Of Control (IOC) and
Dependency Injection
• These are the design patterns that are used to remove
dependency from the programming code. They make
the code easier to test and maintain. Let's understand
this with the following code:
class Employee{
Address address;
Employee(){
address=new Address();
}
}
• In such case, there is dependency between the
Employee and Address (tight coupling).
• In the Inversion of Control scenario, we do this something like this:
class Employee{
Address address;
Employee(Address address){
this.address=address;
}
}
• Thus, IOC makes the code loosely coupled. In such case, there is no
need to modify the code if our logic is moved to new environment.
• In Spring framework, IOC container is responsible to inject the
dependency. We provide metadata to the IOC container either by
XML file or annotation.
• Advantage of Dependency Injection
– makes the code loosely coupled so easy to maintain
– makes the code easy to test
Advantages of Spring Framework
• 1) Predefined Templates
– Spring framework provides templates for JDBC, Hibernate, JPA etc.
technologies. So there is no need to write too much code. It hides the
basic steps of these technologies.
• Let's take the example of JdbcTemplate, you don't need to write the code
for exception handling, creating connection, creating statement,
committing transaction, closing connection etc. You need to write the
code of executing query only. Thus, it save a lot of JDBC code.
• 2) Loose Coupling
– The Spring applications are loosely coupled because of dependency
injection.
• 3) Easy to test
– The Dependency Injection makes easier to test the application. The
EJB or Struts application require server to run the application but
Spring framework doesn't require server.
• 4) Lightweight
– Spring framework is lightweight because of its POJO
implementation. The Spring Framework doesn't force the
programmer to inherit any class or implement any
interface. That is why it is said non-invasive.
• 5) Fast Development
– The Dependency Injection feature of Spring Framework
and it support to various frameworks makes the easy
development of JavaEE application.
• 6) Powerful abstraction
– It provides powerful abstraction to JavaEE specifications
such as JMS, JDBC, JPA and JTA.
• 7) Declarative support
– It provides declarative support for caching, validation,
transactions and formatting.
Spring Modules
• The Spring Framework consists of features
organized into about 20 modules. These
modules are grouped into Core Container,
Data Access/Integration, Web, AOP (Aspect
Oriented Programming), Instrumentation, and
Test, as shown in the following diagram.
• Test
– This layer provides support of testing with JUnit and
TestNG.
• Spring Core Container
– The Spring Core container contains core, beans, context
and expression language (EL) modules.
– Core and Beans
• These modules provide IOC and Dependency Injection features.
– Context
• This module supports internationalization (I18N), EJB, JMS, Basic
Remoting.
– Expression Language
• It is an extension to the EL defined in JSP. It provides support to
setting and getting property values, method invocation, accessing
collections and indexers, named variables, logical and arithmetic
operators, retrieval of objects by name etc.
• AOP, Aspects and Instrumentation
– These modules support aspect oriented programming
implementation where you can use Advices, Pointcuts etc. to
decouple the code.
– The aspects module provides support to integration with
AspectJ.
– The instrumentation module provides support to class
instrumentation and classloader implementations.
• Data Access / Integration
– This group comprises of JDBC, ORM, OXM, JMS and Transaction
modules. These modules basically provide support to interact
with the database.
• Web
– This group comprises of Web, Web-Servlet, Web-Struts and
Web-Portlet. These modules provide support to create web
application.
IoC Container
• The IoC container is responsible to instantiate,
configure and assemble the objects. The IoC
container gets informations from the XML file and
works accordingly. The main tasks performed by
IoC container are:
– to instantiate the application class
– to configure the object
– to assemble the dependencies between the objects
• There are two types of IoC containers. They are:
– BeanFactory
– ApplicationContext
Difference between BeanFactory and
the ApplicationContext
• The org.springframework.beans.factory.
BeanFactory and the org.springframework.context.
ApplicationContext interfaces acts as the IoC container.
The ApplicationContext interface is built on top of the
BeanFactory interface. It adds some extra functionality
than BeanFactory such as simple integration with
Spring's AOP, message resource handling (for I18N),
event propagation, application layer specific context
(e.g. WebApplicationContext) for web application. So it
is better to use ApplicationContext than BeanFactory.

Mais conteúdo relacionado

Mais procurados

Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
Dzmitry Naskou
 
JSF 2.3: Integration with Front-End Frameworks
JSF 2.3: Integration with Front-End FrameworksJSF 2.3: Integration with Front-End Frameworks
JSF 2.3: Integration with Front-End Frameworks
Ian Hlavats
 
Webapplication ppt prepared by krishna ballabh gupta
Webapplication ppt prepared by krishna ballabh guptaWebapplication ppt prepared by krishna ballabh gupta
Webapplication ppt prepared by krishna ballabh gupta
Shivalik college of engineering
 
Devjyotippt
DevjyotipptDevjyotippt
Devjyotippt
Gaurav pathak
 
[2015/2016] Backbone JS
[2015/2016] Backbone JS[2015/2016] Backbone JS
[2015/2016] Backbone JS
Ivano Malavolta
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
Muthuselvam RS
 
Best Practices for JSF, Gameduell 2013
Best Practices for JSF, Gameduell 2013Best Practices for JSF, Gameduell 2013
Best Practices for JSF, Gameduell 2013
Edward Burns
 
JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...
JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...
JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
Hamid Ghorbani
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
Hùng Nguyễn Huy
 
Web apps architecture
Web apps architectureWeb apps architecture
Web apps architecture
Tanmoy Barman
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Hùng Nguyễn Huy
 
Getting Started with Spring Framework
Getting Started with Spring FrameworkGetting Started with Spring Framework
Getting Started with Spring Framework
Edureka!
 
[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS
Ivano Malavolta
 
Concepts of Asp.Net
Concepts of Asp.NetConcepts of Asp.Net
Concepts of Asp.Net
vidyamittal
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
nomykk
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
kamal kotecha
 
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 mvc
Spring mvcSpring mvc
Spring mvc
Harshit Choudhary
 
Java Training in Chennai
Java Training in Chennai Java Training in Chennai
Java Training in Chennai
raj esaki
 

Mais procurados (20)

Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
JSF 2.3: Integration with Front-End Frameworks
JSF 2.3: Integration with Front-End FrameworksJSF 2.3: Integration with Front-End Frameworks
JSF 2.3: Integration with Front-End Frameworks
 
Webapplication ppt prepared by krishna ballabh gupta
Webapplication ppt prepared by krishna ballabh guptaWebapplication ppt prepared by krishna ballabh gupta
Webapplication ppt prepared by krishna ballabh gupta
 
Devjyotippt
DevjyotipptDevjyotippt
Devjyotippt
 
[2015/2016] Backbone JS
[2015/2016] Backbone JS[2015/2016] Backbone JS
[2015/2016] Backbone JS
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
 
Best Practices for JSF, Gameduell 2013
Best Practices for JSF, Gameduell 2013Best Practices for JSF, Gameduell 2013
Best Practices for JSF, Gameduell 2013
 
JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...
JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...
JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 
Web apps architecture
Web apps architectureWeb apps architecture
Web apps architecture
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Getting Started with Spring Framework
Getting Started with Spring FrameworkGetting Started with Spring Framework
Getting Started with Spring Framework
 
[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS
 
Concepts of Asp.Net
Concepts of Asp.NetConcepts of Asp.Net
Concepts of Asp.Net
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
 
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 mvc
Spring mvcSpring mvc
Spring mvc
 
Java Training in Chennai
Java Training in Chennai Java Training in Chennai
Java Training in Chennai
 

Semelhante a 1. Spring intro IoC

Spring ppt
Spring pptSpring ppt
Spring ppt
Mumbai Academisc
 
Spring framework
Spring frameworkSpring framework
Spring framework
Shivi Kashyap
 
Spring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsSpring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggets
Virtual Nuggets
 
Introduction to Spring
Introduction to SpringIntroduction to Spring
Introduction to Spring
Sujit Kumar
 
spring
springspring
spring
Suman Behara
 
Spring
SpringSpring
Spring
Suman Behara
 
Spring
SpringSpring
Spring
komalpreethi
 
Month 3 report
Month 3 reportMonth 3 report
Month 3 report
PRIYANKA FNU
 
Introduction to Spring & Spring BootFramework
Introduction to Spring  & Spring BootFrameworkIntroduction to Spring  & Spring BootFramework
Introduction to Spring & Spring BootFramework
Kongu Engineering College, Perundurai, Erode
 
Framework adoption for java enterprise application development
Framework adoption for java enterprise application developmentFramework adoption for java enterprise application development
Framework adoption for java enterprise application development
Clarence Ho
 
Hybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbaiHybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbai
Vibrant Technologies & Computers
 
스프링 프레임워크
스프링 프레임워크스프링 프레임워크
스프링 프레임워크
Yoonki Chang
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
Mukesh Kumar
 
Spring framework
Spring frameworkSpring framework
Spring framework
Kani Selvam
 
Spring notes
Spring notesSpring notes
Spring notes
Rajeev Uppala
 
Java Spring
Java SpringJava Spring
Java Spring
AathikaJava
 
Spring framework
Spring frameworkSpring framework
The Complete Spring Tutorial
The Complete Spring TutorialThe Complete Spring Tutorial
The Complete Spring Tutorial
cribes
 
Spring framework
Spring frameworkSpring framework
Spring framework
Sonal Poddar
 
Suman
SumanSuman

Semelhante a 1. Spring intro IoC (20)

Spring ppt
Spring pptSpring ppt
Spring ppt
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Spring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsSpring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggets
 
Introduction to Spring
Introduction to SpringIntroduction to Spring
Introduction to Spring
 
spring
springspring
spring
 
Spring
SpringSpring
Spring
 
Spring
SpringSpring
Spring
 
Month 3 report
Month 3 reportMonth 3 report
Month 3 report
 
Introduction to Spring & Spring BootFramework
Introduction to Spring  & Spring BootFrameworkIntroduction to Spring  & Spring BootFramework
Introduction to Spring & Spring BootFramework
 
Framework adoption for java enterprise application development
Framework adoption for java enterprise application developmentFramework adoption for java enterprise application development
Framework adoption for java enterprise application development
 
Hybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbaiHybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbai
 
스프링 프레임워크
스프링 프레임워크스프링 프레임워크
스프링 프레임워크
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Spring notes
Spring notesSpring notes
Spring notes
 
Java Spring
Java SpringJava Spring
Java Spring
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
The Complete Spring Tutorial
The Complete Spring TutorialThe Complete Spring Tutorial
The Complete Spring Tutorial
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Suman
SumanSuman
Suman
 

Último

Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
jpupo2018
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
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
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
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
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
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
 
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
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
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
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
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
 
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
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 

Último (20)

Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
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
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
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
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
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
 
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
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
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
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
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
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 

1. Spring intro IoC

  • 1.
  • 2. Spring Framework • Spring is a lightweight framework. It can be thought of as a framework of frameworks because it provides support to various frameworks such as Struts, Hibernate, Tapestry, EJB, JSF etc. The framework, in broader sense, can be defined as a structure where we find solution of the various technical problems. • The Spring framework comprises several modules such as IOC, AOP, DAO, Context, ORM, WEB MVC etc. We will learn these modules in next page. Let's understand the IOC and Dependency Injection first.
  • 3. Inversion Of Control (IOC) and Dependency Injection • These are the design patterns that are used to remove dependency from the programming code. They make the code easier to test and maintain. Let's understand this with the following code: class Employee{ Address address; Employee(){ address=new Address(); } } • In such case, there is dependency between the Employee and Address (tight coupling).
  • 4. • In the Inversion of Control scenario, we do this something like this: class Employee{ Address address; Employee(Address address){ this.address=address; } } • Thus, IOC makes the code loosely coupled. In such case, there is no need to modify the code if our logic is moved to new environment. • In Spring framework, IOC container is responsible to inject the dependency. We provide metadata to the IOC container either by XML file or annotation. • Advantage of Dependency Injection – makes the code loosely coupled so easy to maintain – makes the code easy to test
  • 5. Advantages of Spring Framework • 1) Predefined Templates – Spring framework provides templates for JDBC, Hibernate, JPA etc. technologies. So there is no need to write too much code. It hides the basic steps of these technologies. • Let's take the example of JdbcTemplate, you don't need to write the code for exception handling, creating connection, creating statement, committing transaction, closing connection etc. You need to write the code of executing query only. Thus, it save a lot of JDBC code. • 2) Loose Coupling – The Spring applications are loosely coupled because of dependency injection. • 3) Easy to test – The Dependency Injection makes easier to test the application. The EJB or Struts application require server to run the application but Spring framework doesn't require server.
  • 6. • 4) Lightweight – Spring framework is lightweight because of its POJO implementation. The Spring Framework doesn't force the programmer to inherit any class or implement any interface. That is why it is said non-invasive. • 5) Fast Development – The Dependency Injection feature of Spring Framework and it support to various frameworks makes the easy development of JavaEE application. • 6) Powerful abstraction – It provides powerful abstraction to JavaEE specifications such as JMS, JDBC, JPA and JTA. • 7) Declarative support – It provides declarative support for caching, validation, transactions and formatting.
  • 7. Spring Modules • The Spring Framework consists of features organized into about 20 modules. These modules are grouped into Core Container, Data Access/Integration, Web, AOP (Aspect Oriented Programming), Instrumentation, and Test, as shown in the following diagram.
  • 8.
  • 9. • Test – This layer provides support of testing with JUnit and TestNG. • Spring Core Container – The Spring Core container contains core, beans, context and expression language (EL) modules. – Core and Beans • These modules provide IOC and Dependency Injection features. – Context • This module supports internationalization (I18N), EJB, JMS, Basic Remoting. – Expression Language • It is an extension to the EL defined in JSP. It provides support to setting and getting property values, method invocation, accessing collections and indexers, named variables, logical and arithmetic operators, retrieval of objects by name etc.
  • 10. • AOP, Aspects and Instrumentation – These modules support aspect oriented programming implementation where you can use Advices, Pointcuts etc. to decouple the code. – The aspects module provides support to integration with AspectJ. – The instrumentation module provides support to class instrumentation and classloader implementations. • Data Access / Integration – This group comprises of JDBC, ORM, OXM, JMS and Transaction modules. These modules basically provide support to interact with the database. • Web – This group comprises of Web, Web-Servlet, Web-Struts and Web-Portlet. These modules provide support to create web application.
  • 11. IoC Container • The IoC container is responsible to instantiate, configure and assemble the objects. The IoC container gets informations from the XML file and works accordingly. The main tasks performed by IoC container are: – to instantiate the application class – to configure the object – to assemble the dependencies between the objects • There are two types of IoC containers. They are: – BeanFactory – ApplicationContext
  • 12. Difference between BeanFactory and the ApplicationContext • The org.springframework.beans.factory. BeanFactory and the org.springframework.context. ApplicationContext interfaces acts as the IoC container. The ApplicationContext interface is built on top of the BeanFactory interface. It adds some extra functionality than BeanFactory such as simple integration with Spring's AOP, message resource handling (for I18N), event propagation, application layer specific context (e.g. WebApplicationContext) for web application. So it is better to use ApplicationContext than BeanFactory.