one of the open source framework spring key features -dependency injection

来源:互联网 发布:淘宝怎么让卖家返现 编辑:程序博客网 时间:2024/04/29 23:57

Dependency injection ,they core function of the spring,as is well known, spring is  the main JEE development stack, the following are the understanding of the DJ:

in the traditional  programming ,there are usually two roles: caller and callee .  when  one instance need assistance of   another instance, caller creates instance of  callee directly.

but in spring ,caller can not immediately instantiate callee , the spring container is in charge of the instance of the callee, and then injects to the caller . that is the dependency injection.

the principle are following:

1 higher lever modules should not depend upon the lower lever modules , they should depend on abstraction level.

2 abstraction should not depend upon details ,the details should depends on abstraction