Applying Inversion of Control to SOA is an interesting idea. It increases the level of decoupling beyond standard implementations of SOA services. It comes with advantages and challenges of course, both of which we discuss.
2. “NORMAL” WAY
I’LL GET THE STUFF AND I’LL HANDLE THINGS
CLIENT
ESB
TASK
SERVICE
ENTITY
SERVICE
ACCOUNT
ENTITY
SERVICE
BALANCE
1,12
2,11
3,6
7,10
4,5 8,9
1. retrieveBalance(IBAN)
2. retrieveBalance(IBAN)
3. retrieveBalance(IBAN)
4. retrieveBalance(IBAN)
5. return balance
6. return balance
7. retrieveAccounts(userId)
8. retrieveAccounts(userId)
9. return List<Account>
10. return List<Account>
11. do magic and return balance
12. return balance
THREEANDAHALFROSES.COM - PATRICE
3. INVERSION OF CONTROL (IOC) WAY
YOU GET THE STUFF AND I’LL HANDLE THINGS
CLIENT
ESB
ENTITY
SERVICE
ACCOUNT
ENTITY
SERVICE
BALANCE
TASK
SERVICE
1,8
2,3 4,5 6,7
1. retrieveBalance(IBAN)
2. retrieveAccounts(userId)
3. return accounts
4. retrieveBalance(IBAN)
5. return balance
6. doMagic(accounts, balance)
7. return balance
8. return balance
THREEANDAHALFROSES.COM - PATRICE
4. ABOUT IOC
WHAT PROBLEMS DOES IT TRY TO SOLVE
▸ Decoupling components and layers in the system
▸ Alleviates a component from being responsible for managing
it's dependencies
▸ Swap dependency implementations in different environments.
▸ Allows a component be tested through mocking of
dependencies.
▸ Provides a mechanism for sharing resources throughout an
application.
Stolen from here: http://www.dofactory.com/topic/1097/what-are-the-benefits-and-dangers-of-ioc-inversion-of-control.aspx
THREEANDAHALFROSES.COM - PATRICE
5. ABOUT IOC
BENEFITS
▸ Makes it easier to test your code. Without it, the code you
are testing is hard to isolate as it will be highly coupled to
the rest of the system and to the ESB.
▸ Useful when developing modular systems. You can replace
components without requiring recompilation.
▸ If done well, independent from runtime container (ESB in
our case)
▸ Due to less requests to the bus, less network overhead
Partially stolen from here: http://www.dofactory.com/topic/1097/what-are-the-benefits-and-dangers-of-ioc-inversion-of-control.aspx
THREEANDAHALFROSES.COM - PATRICE
6. ABOUT IOC
DISADVANTAGES
▸ Dependency on runtime container to wire everything
together (set-up, maintenance, may be challenging to
debug E2E)
▸ you get the input objects even if they were not needed in
the task service logic for some reason.
THREEANDAHALFROSES.COM - PATRICE