Clean Code



Download 3,58 Mb.
Pdf ko'rish
bet163/384
Sana05.04.2022
Hajmi3,58 Mb.
#530298
1   ...   159   160   161   162   163   164   165   166   ...   384
Bog'liq
Clean Code

Listing 11-4 
Spring 2.X configuration file

...
destroy-method="close"
p:driverClassName="com.mysql.jdbc.Driver"
p:url="jdbc:mysql://localhost:3306/mydb"
p:username="me"/>
p:dataSource-ref="appDataSource"/>
13. Adapted from http://www.theserverside.com/tt/articles/article.tss?l=IntrotoSpring25


164
Chapter 11: Systems
Each “bean” is like one part of a nested “Russian doll,” with a domain object for a
Bank
proxied (wrapped) by a data accessor object (DAO), which is itself proxied by a
JDBC driver data source. (See Figure 11-3.)
The client believes it is invoking 
getAccounts()
on a 
Bank
object, but it is actually talk-
ing to the outermost of a set of nested D
ECORATOR
14
objects that extend the basic behavior
of the 
Bank
POJO. We could add other decorators for transactions, caching, and so forth
.
In the application, a few lines are needed to ask the DI container for the top-level
objects in the system, as specified in the XML file.
XmlBeanFactory bf =
new XmlBeanFactory(new ClassPathResource("app.xml", getClass()));
Bank bank = (Bank) bf.getBean("bank");
Because so few lines of Spring-specific Java code are required
the application is almost
completely decoupled from Spring
, eliminating all the tight-coupling problems of systems
like EJB2.
Although XML can be verbose and hard to read,
15
the “policy” specified in these con-
figuration files is simpler than the complicated proxy and aspect logic that is hidden from
view and created automatically. This type of architecture is so compelling that frame-
works like Spring led to a complete overhaul of the EJB standard for version 3. EJB3
p:dataAccessObject-ref="bankDataAccessObject"/>
...

Figure 11-3
The “Russian doll” of decorators
14. [GOF].
15. The example can be simplified using mechanisms that exploit 
convention over configuration
and Java 5 annotations to reduce 
the amount of explicit “wiring” logic required.

Download 3,58 Mb.

Do'stlaringiz bilan baham:
1   ...   159   160   161   162   163   164   165   166   ...   384




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish