摘要
为了解决使用标准Struts框架开发程序时所带来的组件之间的耦合程度比较高的缺点,在标准Struts框架中引入了Dependency Injection(DI)模式。在介绍了DI模式的基本原理和3种实现类型之后,基于该模式对标准的Struts1.2框架进行了扩展,主要加入了设值方法注入功能。扩展框架实现了对ActionForm Bean、数据库连接和一般对象的注入。在实际项目中基于此扩展框架进行了软件开发,发现该框架降低了系统的组件之间的耦合,简化了对单个组件的单元测试,效果非常明显。
In order to solve the shortcoming of the higer coupling between the components while developing with the standard Struts framework, the article intorduces the Dependency Injection (DI) pattern in it. This paper makes a detailed introduction on the basic principle of the DI pattern and its three types of implementation, and extends the standard Struts 1.2 framework by adding the setter injection. The extended framework implements the function of injecting ActionFrom Bean, database connection and general objects. This extended framework has been used to develop a software project. During the development, have found that this framework reduced the coupling between the components of the system greatly, simplified the unit test of the individual component. The result is very obvious.
出处
《计算机技术与发展》
2006年第9期38-40,共3页
Computer Technology and Development
关键词
控制反转
依赖注入
组件
STRUTS框架
inversion of control
dependency injection
component
Struts framework