Sei sulla pagina 1di 12

4/19/2020 Spring IOC container Overview

SIMPLIFYING SEARCH

THE
PROGRAMMING
CONCEPTS
Pages

Home

Spring IOC
container
Overview

April 11, 2020

S
SHARE
pring IoC

container is

responsible for

instantiating,

configuring, and

https://www.consciousprogramming.com/2020/04/spring-ioc-container-overview.html 1/12
4/19/2020 Spring IOC container Overview

assembling the

beans. The Spring

IOC container gets

its instructions on

what objects to

instantiate,

configure, and

assemble by

reading

configuration

metadata. The

configuration

metadata is

represented in

XML, Java

annotations, or

Java code. It lets

you express the

objects that

compose your

application and the

rich

interdependencies

between those

objects.

https://www.consciousprogramming.com/2020/04/spring-ioc-container-overview.html 2/12
4/19/2020 Spring IOC container Overview

There are two types

of IoC containers.

They are:

1. BeanFactory
2. ApplicationCo
ntext

Beanfactory:

The BeanFactory

interface from

org.springframewor

k.beans.factory

package

provides an

advanced

configuration

mechanism

capable of

managing any type

of object. The

BeanFactory

provides the spring

configuration

https://www.consciousprogramming.com/2020/04/spring-ioc-container-overview.html 3/12
4/19/2020 Spring IOC container Overview

framework and

functionality.

Creating Spring

IOC container

using

BeanFactory

The

XmlBeanFactory is
the implementation
class for the
BeanFactory
interface. To use

the BeanFactory,
we need to create
the instance of
XmlBeanFactory
class as given

below:

Resource res = new

XmlBeanFactory fac

https://www.consciousprogramming.com/2020/04/spring-ioc-container-overview.html 4/12
4/19/2020 Spring IOC container Overview

or

ClassPathResource

XmlBeanFactory fac

The constructor of

XmlBeanFactory
class receives the
Resource object so
we need to pass
the resource object

to create the object


of BeanFactory.

ApplicationContex
t

The org.springf

ramework.context

.ApplicationCon

text interface

represents the

https://www.consciousprogramming.com/2020/04/spring-ioc-container-overview.html 5/12
4/19/2020 Spring IOC container Overview

Spring IoC

container.Applicatio
nContext interface
extends
BeanFactory and
specializes the
below additional

capabilities:

Easier
integration with
Spring’s AOP
features

Message
resource
handling (for
use in
internationalizati
on)

Event
publication

Application-
layer specific
contexts such
as
the WebApplic
ationContext
for use in web
applications.
https://www.consciousprogramming.com/2020/04/spring-ioc-container-overview.html 6/12
4/19/2020 Spring IOC container Overview

ApplicationCont

ext adds more

enterprise-specific

functionality. then
BeanFactory.

Creating Spring
IOC

ApplicaitonContext:

The

ClassPathXmlAppli
cationContext class

is one of the

implementation
class of

ApplicationContext
interface. We need

to instantiate the

ClassPathXmlAppli
cationContext class

https://www.consciousprogramming.com/2020/04/spring-ioc-container-overview.html 7/12
4/19/2020 Spring IOC container Overview

to use the

ApplicationContext

as given below

ApplicationContext

context =
new ClassPathXml

ApplicationContext(
"applicationContext

.xml");

SHARE
Comments

Enter your comm

Popular posts from this blog

Java
SE 8
https://www.consciousprogramming.com/2020/04/spring-ioc-container-overview.html 8/12
4/19/2020 Spring IOC container Overview

Progra
mmer
1
Certi
cation
Exam
topics(
OCA
Java
8)
December 14,
2019

Java
Basics De n

e the scope

of …

SHARE
POST A
COMMENT
READ MORE

https://www.consciousprogramming.com/2020/04/spring-ioc-container-overview.html 9/12
4/19/2020 Spring IOC container Overview

What
is
depend
ency
injectio
n and
what
are e
advan
tages?
March 28,
2020

Dependenc

y injection is
a design

pattern that

SHARE
POST A
COMMENT
READ MORE

https://www.consciousprogramming.com/2020/04/spring-ioc-container-overview.html 10/12
4/19/2020 Spring IOC container Overview

Design
philoso
phy of
Spring
Frame
w k
April 11, 2020

Spring helps

to defer

design
decision as…

SHARE
POST A
COMMENT
READ MORE

Archive

Labels

https://www.consciousprogramming.com/2020/04/spring-ioc-container-overview.html 11/12
4/19/2020 Spring IOC container Overview

Report Abuse

Powered by Blogger

https://www.consciousprogramming.com/2020/04/spring-ioc-container-overview.html 12/12

Potrebbero piacerti anche