天空是蓝色的

做好软件为中国 #gcc -c helloworld.c -o helloworld.o //编译目标文件 #gcc helloworld.o -o helloworld //编译成可执行exe #helloworld //运行exe
数据加载中……
理解IOC容器的概念和DI

015.jpg

Inversion of Control/Dependency Injection
IOC容器
相当于一个bean工厂,来管理整个应用程序中使用的bean,来管理这些bean的生命周期;

实现IOC/DI是通过一堆描述文件,IOC容器根据这堆描述文件来实现创建对象提供服务等工作;

一般情况下,我们通过new一个对象并调用这个对象的某个方法来完成服务.

既然有了IOC容器管理概念,那么通过描述文件容器就为我们创建所需要对象和方法.

好处就是减少了硬编码.

There are three different implementation pattern types for IoC:

type-1 Services need to implement a dedicated interface through which they are provided with an object from which they can look up dependencies (other services). This is the pattern used by the earlier containers provided by Excalibur.
type-2 Services dependencies upon are assigned via JavaBeans properties (setter methods). Both HiveMind and Spring use this approach.
type-3 Services dependencies are provided as constructor parameters (and are not exposed as JavaBeans properties). This is the exclusive approach used by PicoContainer, and is also used in HiveMind and Spring.

http://jakarta.apache.org/hivemind/ioc.html

http://www.javaworld.com.tw/confluence/display/opensrc/Spring

posted on 2005-12-23 10:04 bluesky 阅读(736) 评论(0)  编辑  收藏 所属分类: 工作总结


只有注册用户登录后才能发表评论。


网站导航: