SlideShare a Scribd company logo
1 of 35
Mahika Tutorials
Spring Framework
Tutorials
Mahika Tutorials
Using MessageSource
to get text from properties file
INTRODUCTIONTO
SPRING
Mahika Tutorials
Mahika Tutorials
 Spring is a light weight and open source framework created by Rod
Johnson in 2003.
Mahika Tutorials
Spring Application
Spring jars
 Spring framework makes the development of Java/JavaEE application
easy.
Mahika Tutorials
Dtababase Connectivity
Transaction Management
Dependency Injection
AOP
 Spring can be thought of as a framework of frameworks because it provides
support to various frameworks such as Struts, Hibernate, EJB, JSF etc.
Mahika Tutorials
Spring
JSF
EJB
Hibernate
Struts
 Spring enables you to build applications from “plain old Java objects”
(POJOs).
Mahika Tutorials
 Spring framework is said to be a non-invasive means it doesn’t force a
programmer to extend or implement their class from any predefined
class or interface given by Spring API.
Mahika Tutorials
 Spring applications are loosely coupled because of dependency
injection and Inversion of Control(IOC).
Mahika Tutorials
Employee
Address address;
Employee(){
address=newAddress(“XYZ Street ,”Pune”);
}
Employee
Address address;
Third Party
Address
instance
Tight Coupling Loose Coupling
Spring Modules
Mahika Tutorials
Core Container
Mahika Tutorials
 Core and Beans:These modules provide IOC and Dependency Injection features.
 Context:This module supports internationalization (I18N), EJB, JMS, Basic Remoting.
 SpEL: It is an extension to the EL defined in JSP. It provides support to setting and getting property values,
method invocation, accessing collections, named variables, logical and arithmetic operators, retrieval of
objects by name etc.
Data Access / Integration-
Mahika Tutorials
 These modules basically provide support to interact with the database.
 The JDBC module removes the need to do tedious JDBC coding.
 ORM module is used to tie up with ORM tools such as hibernate.
Web
Mahika Tutorials
 These modules provide support to create web application.
Test
 This module supports the testing of Spring components with JUnit orTestNG.
Mahika Tutorials
Mahika Tutorials
Dependency Injection &IOC
Dependency Injection
 Dependency Injection (DI) is a software design pattern that deals with how components get hold of their
dependencies.
 A class X has a dependency to classY, if class X uses classY as a variable.
 Java components / classes should be as independent as possible of other Java classes.
 This increases the possibility to reuse these classes and to test them independently of other classes(UnitTesting).
 Dependency injection is a style of object configuration in which an object’s fields are set by an external entity, in other
words objects are configured by an external entity.
 Dependency injection is an alternative to having the object configure itself.
Mahika Tutorials
class X
{
Y y;
……………
}
Dependency Injection and Inversion of Control
Mahika Tutorials
A
C
B
Dependency
A
C
B
Injection
Inversion of Control is a principle by which the control of objects is transferred to a
container or framework.
Dependency injection is a pattern through which IoC is implemented, 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 container rather than by the objects themselves.
A class should not configure itself but should be configured from outside.
Mahika Tutorials
Dependency Injection and Inversion of Control
Dependency Injection and Inversion of Control
 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.
 IOC makes the application easy to test.
 In Spring framework, IOC container is responsible to inject the
dependency. We provide metadata to the IOC container either by XML
file or annotation
Mahika Tutorials
Dependency Injection
Spring framework provides two ways to inject dependency
By Constructor (Constructor Injection)-In the case of constructor-based dependency
injection, the container will invoke a constructor with arguments each representing a
dependency we want to set.
By Setter method (Setter Injection)-For setter-based DI, the container will call setter
methods of our class.
Mahika Tutorials
class Employee{
Address address;
Employee(){
address=newAddress(“XYZ Street”, ”Pune”, ”MH”);
}
…………………..
}
With IOC (setter Injection)Without IOC
class Employee{
Address address;
public void setAddress(Address address){
this.address=address;
}
………
}
With IOC (constructor Injection)
class Employee{
Address address;
Employee(Address address){
this.address=address;
………
}
}
Mahika Tutorials
Mahika Tutorials
BeanFactory & AplicationContext
IOC
 In Spring framework, IOC container is responsible to inject the dependencies.We provide metadata
to the IOC container either by XML file or annotation.
 The IoC container is responsible to instantiate, configure and assemble the objects.
Mahika Tutorials
BeanFactory
ApplicationContext
IOC
containers
BeanFactory
Mahika Tutorials
 Spring BeanFactory Container is the simplest container which provides basic support for DI.
 It is defined by org.springframework.beans.factory.BeanFactory interface.
 There are many implementations of BeanFactory interface . The most commonly used
BeanFactory implementation is –
org.springframework.beans.factory.xml.XmlBeanFactory
 Example-
Resource resource=new ClassPathResource(“Beans.xml");
BeanFactory factory=new XmlBeanFactory(resource);
 The Resource interface has many implementaions. Two mainly used are:
1)org.springframework.core.io.FileSystemResource :Loads the resource from underlying file
system.
Example-
BeanFactory bfObj = new XmlBeanFactory(new FileSystemResource ("c:/beansconfig.xml"));
2)org.springframework.core.io.ClassPathResource:Loads the resource from classpath.
ApplicationContext
The ApplicationContext container is Spring’s advanced container.
It is defined by org.springframework.context.ApplicationContext interface.
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 etc.
There are many implementations of ApplicationContext interface .The most
commonly used ApplicationContext implementation is –
org.springframework.context.support.ClassPathXmlApplicationContext
 Example-
ApplicationContext context=new ClassPathXmlApplicationContext("Beans.xml");
Mahika Tutorials
Mahika Tutorials
Mahika Tutorials
Spring Autowiring
Autowiring in Spring
Mahika Tutorials
 Autowiring means injecting the object dependency implicitly.
 It internally uses setter or constructor injection.
 It works with reference only.
 Autowiring can't be used to inject primitive and string values.
 By default autowiring is disabled in spring framework.
 Autowiring can be performed by either using “autowire” attribute in <bean> or by using @Autowired annotation.
Without Autowiring
Mahika Tutorials
public class Employee {
private int id;
private String name;
private Address address;
…….
}
…….
<bean id="address" class="com.tutorials.demo.Address">
<property name="street" value="Park Street"></property>
<property name="city" value="Pune"></property>
<property name="state" value="Maharashtra"></property>
</bean>
<bean id="emp" class="com.tutorials.demo.Employee">
<property name="id" value="111"></property>
<property name="name" value="Ram"></property>
<property name="address" ref="address"></property>
</bean>
……….
With Autowiring
Mahika Tutorials
public class Employee {
private int id;
private String name;
private Address address;
…….
}
…….
<bean id="address" class="com.tutorials.demo.Address">
<property name="street" value="Park Street"></property>
<property name="city" value="Pune"></property>
<property name="state" value="Maharashtra"></property>
</bean>
<bean id="emp" class="com.tutorials.demo.Employee“ autowire=“byName">
<property name="id" value="111"></property>
<property name="name" value="Ram"></property>
</bean>
……….
Autowiring modes
Mahika Tutorials
No. Mode Description
1) no It is the default autowiring mode. It means no autowiring bydefault.
2) byName The byName mode injects the object dependency according to name of the bean. In such
case, property name and bean name must be same. It internally calls setter method.
3) byType The byType mode injects the object dependency according to type. So property name and
bean name can be different. It internally calls setter method.
4) constructor The constructor mode injects the dependency by calling the constructor of the class. It calls
the constructor having large number of parameters.
5) autodetect It is deprecated since Spring 3.
Mahika Tutorials
Mahika Tutorials
Bean Scopes
Autowiring in Spring
Mahika Tutorials
 Autowiring means injecting the object dependency implicitly.
 It internally uses setter or constructor injection.
 It works with reference only.
 Autowiring can't be used to inject primitive and string values.
 By default autowiring is disabled in spring framework.
 Autowiring can be performed by either using “autowire” attribute in <bean> or by using @Autowired annotation.
Mahika Tutorials

More Related Content

What's hot

Introduction to Hibernate Framework
Introduction to Hibernate FrameworkIntroduction to Hibernate Framework
Introduction to Hibernate FrameworkRaveendra R
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate pptAneega
 
Functional Dependency Injection in C#
Functional Dependency Injection in C#Functional Dependency Injection in C#
Functional Dependency Injection in C#Thomas Jaskula
 
Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesecosio GmbH
 
Types of Dependency Injection in Spring
Types of Dependency Injection in SpringTypes of Dependency Injection in Spring
Types of Dependency Injection in SpringSunil kumar Mohanty
 
Hibernate tutorial for beginners
Hibernate tutorial for beginnersHibernate tutorial for beginners
Hibernate tutorial for beginnersRahul Jain
 
Hibernate Interview Questions
Hibernate Interview QuestionsHibernate Interview Questions
Hibernate Interview QuestionsSyed Shahul
 
Massively Scalable Applications - TechFerry
Massively Scalable Applications - TechFerryMassively Scalable Applications - TechFerry
Massively Scalable Applications - TechFerryTechFerry
 
Introduction to OO, Java and Eclipse/WebSphere
Introduction to OO, Java and Eclipse/WebSphereIntroduction to OO, Java and Eclipse/WebSphere
Introduction to OO, Java and Eclipse/WebSphereeLink Business Innovations
 

What's hot (19)

Introduction to Hibernate Framework
Introduction to Hibernate FrameworkIntroduction to Hibernate Framework
Introduction to Hibernate Framework
 
EJB Clients
EJB ClientsEJB Clients
EJB Clients
 
Introduction to JPA Framework
Introduction to JPA FrameworkIntroduction to JPA Framework
Introduction to JPA Framework
 
Hibernate II
Hibernate IIHibernate II
Hibernate II
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Data access
Data accessData access
Data access
 
Functional Dependency Injection in C#
Functional Dependency Injection in C#Functional Dependency Injection in C#
Functional Dependency Injection in C#
 
JPA For Beginner's
JPA For Beginner'sJPA For Beginner's
JPA For Beginner's
 
Spring Framework-II
Spring Framework-IISpring Framework-II
Spring Framework-II
 
Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examples
 
Introduction to Hibernate
Introduction to HibernateIntroduction to Hibernate
Introduction to Hibernate
 
Types of Dependency Injection in Spring
Types of Dependency Injection in SpringTypes of Dependency Injection in Spring
Types of Dependency Injection in Spring
 
Overview of JEE Technology
Overview of JEE TechnologyOverview of JEE Technology
Overview of JEE Technology
 
Hibernate tutorial for beginners
Hibernate tutorial for beginnersHibernate tutorial for beginners
Hibernate tutorial for beginners
 
Technical Interview
Technical InterviewTechnical Interview
Technical Interview
 
Hibernate Interview Questions
Hibernate Interview QuestionsHibernate Interview Questions
Hibernate Interview Questions
 
Massively Scalable Applications - TechFerry
Massively Scalable Applications - TechFerryMassively Scalable Applications - TechFerry
Massively Scalable Applications - TechFerry
 
Spring Framework - III
Spring Framework - IIISpring Framework - III
Spring Framework - III
 
Introduction to OO, Java and Eclipse/WebSphere
Introduction to OO, Java and Eclipse/WebSphereIntroduction to OO, Java and Eclipse/WebSphere
Introduction to OO, Java and Eclipse/WebSphere
 

Similar to Spring FrameWork Tutorials Java Language

Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring FrameworkRajind Ruparathna
 
Spring IOC and DAO
Spring IOC and DAOSpring IOC and DAO
Spring IOC and DAOAnushaNaidu
 
Unit No 2 Objects and Classes.pptx
Unit No 2 Objects and Classes.pptxUnit No 2 Objects and Classes.pptx
Unit No 2 Objects and Classes.pptxDrYogeshDeshmukh1
 
Dependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony ContainerDependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony ContainerDiego Lewin
 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depthVinay Kumar
 
[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 JSIvano Malavolta
 
Java J2EE Interview Questions Part 2
Java J2EE Interview Questions Part 2Java J2EE Interview Questions Part 2
Java J2EE Interview Questions Part 2javatrainingonline
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answersKrishnaov
 
2-0. Spring ecosytem.pdf
2-0. Spring ecosytem.pdf2-0. Spring ecosytem.pdf
2-0. Spring ecosytem.pdfDeoDuaNaoHet
 
Spring from a to Z
Spring from  a to ZSpring from  a to Z
Spring from a to Zsang nguyen
 
Ef Poco And Unit Testing
Ef Poco And Unit TestingEf Poco And Unit Testing
Ef Poco And Unit TestingJames Phillips
 
JAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp conceptsJAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp conceptsRahul Malhotra
 
Toms introtospring mvc
Toms introtospring mvcToms introtospring mvc
Toms introtospring mvcGuo Albert
 

Similar to Spring FrameWork Tutorials Java Language (20)

Introduction to Hibernate Framework
Introduction to Hibernate FrameworkIntroduction to Hibernate Framework
Introduction to Hibernate Framework
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Spring IOC and DAO
Spring IOC and DAOSpring IOC and DAO
Spring IOC and DAO
 
Unit No 2 Objects and Classes.pptx
Unit No 2 Objects and Classes.pptxUnit No 2 Objects and Classes.pptx
Unit No 2 Objects and Classes.pptx
 
Spring core
Spring coreSpring core
Spring core
 
Dependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony ContainerDependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony Container
 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depth
 
[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
 
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 interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
 
2-0. Spring ecosytem.pdf
2-0. Spring ecosytem.pdf2-0. Spring ecosytem.pdf
2-0. Spring ecosytem.pdf
 
Spring Basics
Spring BasicsSpring Basics
Spring Basics
 
Spring from a to Z
Spring from  a to ZSpring from  a to Z
Spring from a to Z
 
02 objective-c session 2
02  objective-c session 202  objective-c session 2
02 objective-c session 2
 
Ef Poco And Unit Testing
Ef Poco And Unit TestingEf Poco And Unit Testing
Ef Poco And Unit Testing
 
JAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp conceptsJAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp concepts
 
CDI @javaonehyderabad
CDI @javaonehyderabadCDI @javaonehyderabad
CDI @javaonehyderabad
 
Toms introtospring mvc
Toms introtospring mvcToms introtospring mvc
Toms introtospring mvc
 
Spring survey
Spring surveySpring survey
Spring survey
 

Recently uploaded

The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 

Recently uploaded (20)

The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 

Spring FrameWork Tutorials Java Language

  • 2. Mahika Tutorials Using MessageSource to get text from properties file
  • 4.  Spring is a light weight and open source framework created by Rod Johnson in 2003. Mahika Tutorials Spring Application Spring jars
  • 5.  Spring framework makes the development of Java/JavaEE application easy. Mahika Tutorials Dtababase Connectivity Transaction Management Dependency Injection AOP
  • 6.  Spring can be thought of as a framework of frameworks because it provides support to various frameworks such as Struts, Hibernate, EJB, JSF etc. Mahika Tutorials Spring JSF EJB Hibernate Struts
  • 7.  Spring enables you to build applications from “plain old Java objects” (POJOs). Mahika Tutorials
  • 8.  Spring framework is said to be a non-invasive means it doesn’t force a programmer to extend or implement their class from any predefined class or interface given by Spring API. Mahika Tutorials
  • 9.  Spring applications are loosely coupled because of dependency injection and Inversion of Control(IOC). Mahika Tutorials Employee Address address; Employee(){ address=newAddress(“XYZ Street ,”Pune”); } Employee Address address; Third Party Address instance Tight Coupling Loose Coupling
  • 11. Core Container Mahika Tutorials  Core and Beans:These modules provide IOC and Dependency Injection features.  Context:This module supports internationalization (I18N), EJB, JMS, Basic Remoting.  SpEL: It is an extension to the EL defined in JSP. It provides support to setting and getting property values, method invocation, accessing collections, named variables, logical and arithmetic operators, retrieval of objects by name etc.
  • 12. Data Access / Integration- Mahika Tutorials  These modules basically provide support to interact with the database.  The JDBC module removes the need to do tedious JDBC coding.  ORM module is used to tie up with ORM tools such as hibernate.
  • 13. Web Mahika Tutorials  These modules provide support to create web application. Test  This module supports the testing of Spring components with JUnit orTestNG.
  • 16. Dependency Injection  Dependency Injection (DI) is a software design pattern that deals with how components get hold of their dependencies.  A class X has a dependency to classY, if class X uses classY as a variable.  Java components / classes should be as independent as possible of other Java classes.  This increases the possibility to reuse these classes and to test them independently of other classes(UnitTesting).  Dependency injection is a style of object configuration in which an object’s fields are set by an external entity, in other words objects are configured by an external entity.  Dependency injection is an alternative to having the object configure itself. Mahika Tutorials class X { Y y; …………… }
  • 17. Dependency Injection and Inversion of Control Mahika Tutorials A C B Dependency A C B Injection
  • 18. Inversion of Control is a principle by which the control of objects is transferred to a container or framework. Dependency injection is a pattern through which IoC is implemented, 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 container rather than by the objects themselves. A class should not configure itself but should be configured from outside. Mahika Tutorials Dependency Injection and Inversion of Control
  • 19. Dependency Injection and Inversion of Control  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.  IOC makes the application easy to test.  In Spring framework, IOC container is responsible to inject the dependency. We provide metadata to the IOC container either by XML file or annotation Mahika Tutorials
  • 20. Dependency Injection Spring framework provides two ways to inject dependency By Constructor (Constructor Injection)-In the case of constructor-based dependency injection, the container will invoke a constructor with arguments each representing a dependency we want to set. By Setter method (Setter Injection)-For setter-based DI, the container will call setter methods of our class. Mahika Tutorials class Employee{ Address address; Employee(){ address=newAddress(“XYZ Street”, ”Pune”, ”MH”); } ………………….. } With IOC (setter Injection)Without IOC class Employee{ Address address; public void setAddress(Address address){ this.address=address; } ……… } With IOC (constructor Injection) class Employee{ Address address; Employee(Address address){ this.address=address; ……… } }
  • 22. Mahika Tutorials BeanFactory & AplicationContext
  • 23. IOC  In Spring framework, IOC container is responsible to inject the dependencies.We provide metadata to the IOC container either by XML file or annotation.  The IoC container is responsible to instantiate, configure and assemble the objects. Mahika Tutorials BeanFactory ApplicationContext IOC containers
  • 24. BeanFactory Mahika Tutorials  Spring BeanFactory Container is the simplest container which provides basic support for DI.  It is defined by org.springframework.beans.factory.BeanFactory interface.  There are many implementations of BeanFactory interface . The most commonly used BeanFactory implementation is – org.springframework.beans.factory.xml.XmlBeanFactory  Example- Resource resource=new ClassPathResource(“Beans.xml"); BeanFactory factory=new XmlBeanFactory(resource);  The Resource interface has many implementaions. Two mainly used are: 1)org.springframework.core.io.FileSystemResource :Loads the resource from underlying file system. Example- BeanFactory bfObj = new XmlBeanFactory(new FileSystemResource ("c:/beansconfig.xml")); 2)org.springframework.core.io.ClassPathResource:Loads the resource from classpath.
  • 25. ApplicationContext The ApplicationContext container is Spring’s advanced container. It is defined by org.springframework.context.ApplicationContext interface. 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 etc. There are many implementations of ApplicationContext interface .The most commonly used ApplicationContext implementation is – org.springframework.context.support.ClassPathXmlApplicationContext  Example- ApplicationContext context=new ClassPathXmlApplicationContext("Beans.xml"); Mahika Tutorials
  • 28. Autowiring in Spring Mahika Tutorials  Autowiring means injecting the object dependency implicitly.  It internally uses setter or constructor injection.  It works with reference only.  Autowiring can't be used to inject primitive and string values.  By default autowiring is disabled in spring framework.  Autowiring can be performed by either using “autowire” attribute in <bean> or by using @Autowired annotation.
  • 29. Without Autowiring Mahika Tutorials public class Employee { private int id; private String name; private Address address; ……. } ……. <bean id="address" class="com.tutorials.demo.Address"> <property name="street" value="Park Street"></property> <property name="city" value="Pune"></property> <property name="state" value="Maharashtra"></property> </bean> <bean id="emp" class="com.tutorials.demo.Employee"> <property name="id" value="111"></property> <property name="name" value="Ram"></property> <property name="address" ref="address"></property> </bean> ……….
  • 30. With Autowiring Mahika Tutorials public class Employee { private int id; private String name; private Address address; ……. } ……. <bean id="address" class="com.tutorials.demo.Address"> <property name="street" value="Park Street"></property> <property name="city" value="Pune"></property> <property name="state" value="Maharashtra"></property> </bean> <bean id="emp" class="com.tutorials.demo.Employee“ autowire=“byName"> <property name="id" value="111"></property> <property name="name" value="Ram"></property> </bean> ……….
  • 31. Autowiring modes Mahika Tutorials No. Mode Description 1) no It is the default autowiring mode. It means no autowiring bydefault. 2) byName The byName mode injects the object dependency according to name of the bean. In such case, property name and bean name must be same. It internally calls setter method. 3) byType The byType mode injects the object dependency according to type. So property name and bean name can be different. It internally calls setter method. 4) constructor The constructor mode injects the dependency by calling the constructor of the class. It calls the constructor having large number of parameters. 5) autodetect It is deprecated since Spring 3.
  • 34. Autowiring in Spring Mahika Tutorials  Autowiring means injecting the object dependency implicitly.  It internally uses setter or constructor injection.  It works with reference only.  Autowiring can't be used to inject primitive and string values.  By default autowiring is disabled in spring framework.  Autowiring can be performed by either using “autowire” attribute in <bean> or by using @Autowired annotation.