java spring ioc module
TRANSCRIPT
-
8/11/2019 JAVA Spring IOC Module
1/10
Apex T. G. India Pvt. Ltd
Inversion of ControlSpring Framework
http://apextgi.in/http://apextgi.in/ -
8/11/2019 JAVA Spring IOC Module
2/10
1
IOC Dependency Injection is the act of injecting
dependencies into an Object.
Inversion of Contro is the genera stye of !sing
dependency Injection to "ire together appication
ayers.
#ence $pring is an Inversion of Contro container.
That is% it is a container that handes Dependency
Injection for yo!.
-
8/11/2019 JAVA Spring IOC Module
3/10
1
IOC An Inversion of Contro &IoC' Container is !tiities
that provide a consistent &and si(pe)' API to
(any other technoogies &*D+C% O,-%AOP%
Decarative Transactions% etc'.
-ini(ie dependencies on $pring.
-ini(ie dependencies bet"een a ayers of an
appication.
-
8/11/2019 JAVA Spring IOC Module
4/10
1
IOC A appication code sho!d be testabe% "itho!t an
appication server or other co(pex environ(ent.
/!y factor the APIs &the 02 case sho!d be
acco(pished in one ine of code)'.
A appication code sho!d be testabe% "itho!t an
appication server or other co(pex environ(ent.
-
8/11/2019 JAVA Spring IOC Module
5/10
1
IOC /!y factor the APIs &the 02 case sho!d be
acco(pished in one ine of code)'.
IOC is a abo!t Object dependencies. Traditiona 3P!3 approach4
Direct instantiation As5ing a /actory for an i(pe(entation Loo5ing !p a service via *6DI.
-
8/11/2019 JAVA Spring IOC Module
6/10
1
IOC 7 P!sh Approach 74 $o(ething o!tside of the
Object 3p!shes3 its dependencies into it. The
Object has no 5no"edge of ho" it gets its
dependencies% it j!st ass!(es they are there.
The 3P!sh3 approach is caed 3Dependency
Injection3.
There is t"o reason to !se dependency injection
1st Loose Co!ping and 8nd is Testabity.
-
8/11/2019 JAVA Spring IOC Module
7/10
1
Loose Co!ping Loose Co!ping is i(proved beca!se it isn9t hard:
code dependencies bet"een ayers and (od!es.
Instead It con;g!re the(&$pring +ean object'
o!tside of the code. This (a5es it easy to s"ap in
a ne" i(pe(entation of a service% or brea5 o< a
(od!e and re!se it ese"here.
-
8/11/2019 JAVA Spring IOC Module
8/10
1
Testabity Testabiity is i(proved beca!se yo!r Objects don9t
5no" or care "hat environ(ent they9re in as ong
as so(eone injects their dependencies. #ence yo!
can depoy Objects into a test environ(ent and
inject -oc5 Objects for their dependencies "ith
ease.
-
8/11/2019 JAVA Spring IOC Module
9/10
1
IOC I(pe(entation create a con;g!ration ;e in "hich de;ne concrete
3beans3 for the interfaces bet"een ayers.
Then "ire the appication together by stating
"hich beans are dependent on each other.
6o"% instantiate a $pring object by !sing IOC
container +ean/actory and AppicationContext. It is
a type of bean factory that "i instantiate a other
beans and hande dependency injection.
-
8/11/2019 JAVA Spring IOC Module
10/10
Thanks
facebook.com/apex.tgi
twitter.com/ApextgiNoida
pinterest.com/apextgi
Stay Connected with us for more chapters on JAVA
https://www.facebook.com/apex.tgihttps://twitter.com/ApextgiNoidahttp://www.pinterest.com/apextgihttp://www.pinterest.com/apextgihttp://www.pinterest.com/apextgihttps://twitter.com/ApextgiNoidahttps://twitter.com/ApextgiNoidahttps://www.facebook.com/apex.tgi