0% found this document useful (0 votes)
36 views

Spring Short Notes

The document discusses two common approaches for assembling dependent objects in Java - using a bean factory or application context. The bean factory approach creates objects using the new operator while the application context approach uses dependency injection. Both approaches allow removing tight coupling between objects by resolving dependencies at runtime rather than compile time.

Uploaded by

Sagar Kalbhor
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Spring Short Notes

The document discusses two common approaches for assembling dependent objects in Java - using a bean factory or application context. The bean factory approach creates objects using the new operator while the application context approach uses dependency injection. Both approaches allow removing tight coupling between objects by resolving dependencies at runtime rather than compile time.

Uploaded by

Sagar Kalbhor
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

6pingBont 2003 Two ways by By Cohsrucfor.

of - By Settr method
ahtoelaht ameoorsk-s Frsaeuoenk Constucdor
Ex.Hibemat. paimiHve 8sing Basel values,
1 Employee .yavg 2) Pepen dent objec
PModule LO $) Callec Hon values ee,
-)
Tesr. java
4Constucor. <-(id)
Ermptoyee. Tamg name) i
methed -ngme)

bean id ='e' class c om,.javatpoint.Epp


(id,nac
LOC Twerston of Conoo Desn pattn <K-7,
tto edute depend,.
due depend. Conshaructor-4m value : "1" pe ="iot>K
DT Depndeney Tn </bean>
Frrory pm,
Responsibe Jo Intechopfe Cepling) Contxta
OC Test class ges Hhe bean 4vom Applieain
dependey Adneanfaqes Calls shooC)..
p22 Annohahon
XML T o Test
TP as To mayan <bean d=e"
class*-
value=" ushik"> { / _ >
consoyetor-asg

inbtanhate applcafjon class bean.


IOC Containes Confiq. ob Kbean d e " elass </->
Two Types of Conatne to assemble. depe. betohjes yalue" "?
Kcenghayc lor-ama
"L" tpe:'int{/-
Beaofacomy.
APplhtaHoy Contex F Censda aq value
</ bean
Bete to use APPliAtiBD Context than Beaofach sefs used to dene s e
Dependent Obj
Beo Stmple imteqcoatHon over spoing keP. oFanother obje
message Rosouce Handing Emploryee Tama
a elass = " _
bean id
APPiralton layer spec fte tontext Addmey,Tan
constucter-ar

. Using Bean Facfory, xmLBeanFacfoy


new Class Path Pesoure bean Td='e' class A< bean.
Resouce res =
value =
* >{
bnsay duraa
Bean Factory pean
2. Usin Applteaiorn Confext
MLBeanFache7()
Application Conlext contuxt=
object KTEf bean
= 'ai'/>

<tconstrue fm a
ne
Classfat) xMLAppltcatonContuxt,) s uesHon java
nl K bean
Dependeny
O O

njrchor Colleohion
ARplajioy Cenlert
a) Ser

nemoves dependeny
3) a. Tesr java
bean id=
"e" class " .
hence Easy To anage3 8 1 > </
constuctor -arg2value
Dependeny lookup Apprvach ohere wege Resoun alue " °>Rl
aftur demand
conssuator -ara
pooblemns
We pwvtdeinfoomation Klist>
Replace
Nalue>
Tight-Coupling ythe extena soya Knaalue
Kalue Ser
Se
Nalue>
N o t easy as L
fer TeshingSych0Dse ile, Ma
oupled
>easy to es /esnsFouchr-ag

You might also like