spring framework & inversion of control
TRANSCRIPT
![Page 1: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/1.jpg)
Spring Framework & Inversion of Control
By Nazim Sitmanbetov
![Page 2: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/2.jpg)
Preconditions Keep calm Sit back Relax
![Page 3: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/3.jpg)
Inversion of Control OOP principle, not design pattern One of
![Page 4: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/4.jpg)
Principle in OOP Modules depend on abstractions Low level modules do not depend on
high level modules
![Page 5: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/5.jpg)
Modules depend on abstractions
Bad Good
![Page 6: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/6.jpg)
Low level modules do not depend on high level modules
Bad Good
Tip: Avoid cyclic dependencies
![Page 7: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/7.jpg)
IoC implementations Factory Method Service Locator Dependency Injection (DI)
![Page 8: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/8.jpg)
Factory Method
![Page 9: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/9.jpg)
Service Locator
![Page 10: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/10.jpg)
Dependency Injection Allow client of module to set
dependencyModule Client
![Page 11: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/11.jpg)
Achievement unlocked
![Page 12: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/12.jpg)
Framework
Java Light-weight Open Source
![Page 13: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/13.jpg)
What means Light-Weight? No container requirements Quick start Application easy-to-test
![Page 14: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/14.jpg)
Spring & IoC Dependency Injection Service Locator
![Page 15: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/15.jpg)
Spring & Dependency InjectionXML Based Configurationmcdonalds-with-kazatin.xml
Java Program
![Page 16: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/16.jpg)
Spring & Service LocatorAnnotation Basedmcdonalds-locator.xml
![Page 17: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/17.jpg)
Spring & Service Locator
![Page 18: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/18.jpg)
Dependency Injection vs Service Locator
DI Service Locator
• Imperative• Can be used with
existing classes
• Declarative• Need to modify
existing classes
![Page 19: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/19.jpg)
Spring components
![Page 20: Spring framework & inversion of control](https://reader033.vdocuments.us/reader033/viewer/2022052522/554f8509b4c9052a518b4e59/html5/thumbnails/20.jpg)
Time to cook