spring framework & inversion of control

20
Spring Framework & Inversion of Control By Nazim Sitmanbetov

Upload: nazim-sitmanbetov

Post on 10-May-2015

237 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Spring framework & inversion of control

Spring Framework & Inversion of Control

By Nazim Sitmanbetov

Page 2: Spring framework & inversion of control

Preconditions Keep calm Sit back Relax

Page 3: Spring framework & inversion of control

Inversion of Control OOP principle, not design pattern One of

Page 4: Spring framework & inversion of control

Principle in OOP Modules depend on abstractions Low level modules do not depend on

high level modules

Page 5: Spring framework & inversion of control

Modules depend on abstractions

Bad Good

Page 6: Spring framework & inversion of control

Low level modules do not depend on high level modules

Bad Good

Tip: Avoid cyclic dependencies

Page 7: Spring framework & inversion of control

IoC implementations Factory Method Service Locator Dependency Injection (DI)

Page 8: Spring framework & inversion of control

Factory Method

Page 9: Spring framework & inversion of control

Service Locator

Page 10: Spring framework & inversion of control

Dependency Injection Allow client of module to set

dependencyModule Client

Page 11: Spring framework & inversion of control

Achievement unlocked

Page 12: Spring framework & inversion of control

Framework

Java Light-weight Open Source

Page 13: Spring framework & inversion of control

What means Light-Weight? No container requirements Quick start Application easy-to-test

Page 14: Spring framework & inversion of control

Spring & IoC Dependency Injection Service Locator

Page 15: Spring framework & inversion of control

Spring & Dependency InjectionXML Based Configurationmcdonalds-with-kazatin.xml

Java Program

Page 16: Spring framework & inversion of control

Spring & Service LocatorAnnotation Basedmcdonalds-locator.xml

Page 17: Spring framework & inversion of control

Spring & Service Locator

Page 18: Spring framework & inversion of control

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

Spring components

Page 20: Spring framework & inversion of control

Time to cook