Forms of Dependency Injection
http://en.wikipedia.org/wiki/Dependency_injection
Martin Fowler identifies three ways in which an object can get a reference to an external module, according to the pattern used to provide the dependency:
依照提供依賴項時使用的模式,Martin Fowler定義了三種對象可以從得到一個外部模塊引用的方式:
- Type 1 or interface injection, in which the exported module provides an interface that its users must implement in order to get the dependencies at runtime (as introduced by Borland Delphi and followed up by C++Builder and JBuilder[citation needed]).
- Type 2 or setter injection, in which the dependent module exposes a setter method which the framework uses to inject the dependency.
- Type 3 or constructor injection, in which the dependencies are provided through the class constructor. This is the main form used by PicoContainer, although it also supports setter injection.
- 類型1 接口注入,外部模塊提供一個接口,使用者必須實現(xiàn)此接口以在運行期得到依賴項(Borland Delphi引入,并在C++ Builder和JBuilder中繼續(xù)運用)。
- 類型2 設(shè)置器注入,使用者暴露一個設(shè)置器方法,框架將使用此方法注入依賴項。
- 類型3 構(gòu)造器注入,依賴項通過類構(gòu)造函數(shù)提供。這是PicoContainer使用的主要方式(盡管它同時也支持設(shè)置器注入)。
The open source Yan Container[1] provides support for arbitrary types of injection[2] besides the common ones defined above.
除了前列的幾種普通形式外,開源項目Yan Container還對任意形式的注入提供了支持。
Existing frameworks
現(xiàn)有框架
Dependency injection frameworks exist for a number of platforms and languages including:
在一些平臺和語言中都有依賴注入框架,包括:
ActionScript
- Prana Framework
- di-as3
- Syringe
- lowRa (AS3)
- Pixlib (AS2)
- VEGAS and AndromedA this IOC extension.(AS3/AS2/SSAS) (see Introduction IOC based ECMAScript notation)
C++
- Autumn Framework
- PocoCapsule/C++ IoC and DSM Framework
- QtIocContainer
- C++ Builder coupling dependency injection and component based assembly
ColdFusion
Delphi
Java
- Azuki
- Butterfly Container
- iPOJO
- Google Guice
- HiveMind
- JBoss Microcontainer
- PicoContainer
- Openxava
- JBuilder coupling dependency injection and component based assembly
- simject
- Seasar
- Spring Framework
- J2EE 5 / EJB 3
- Naked Objects
- miocc - Microscopic Inversion of Control Container
Java 2 Micro Edition
- Israfil micro container (CLDC 1.1)
.NET
- Autofac
- Castle MicroKernel/Windsor
- ObjectBuilder
- PicoContainer.NET
- Puzzle.NFactory
- Spring.NET
- StructureMap
- Ninject
- Unity
- NauckIT.MicroKernel
- WINTER4NET
PHP4
PHP5
Perl
Python
Ruby
See also
參見
- Closure (computer science) is a method for initializing the dependencies of a callback function in functional programming.
- Strategy pattern
- Architecture description language
- 閉包(計算機科學(xué))是一種在函數(shù)式編程中初始化回調(diào)函數(shù)依賴的方法
- 策略模式
- 架構(gòu)描述語言
External links
外部鏈接
- Inversion of Control Containers and the Dependency Injection pattern - Martin Fowler.
- Dependency Injection & Testable Objects: Designing loosely coupled and testable objects - Jeremy Weiskotten; Dr. Dobb's Journal, May 2006.
- Design Patterns: Dependency Injection -- MSDN Magazine, September 2005
- Writing More Testable Code with Dependency Injection -- Developer.com, October 2006
- Domain Specific Modeling (DSM) in IoC frameworks
- Prasanna, Dhanji R. (2008). Dependency Injection. Manning Publications. ISBN 193398855X.
- What is Dependency Injection? - An alternative explanation - Jakob Jenkov
- The Rich Engineering Heritage Behind Dependency Injection - Andrew McVeigh - A detailed history of dependency injection.
Retrieved from "http://en.wikipedia.org/wiki/Dependency_injection"
Categories: Software components | Software architecture
Hidden categories: Articles to be merged since June 2008 | Articles lacking in-text citations | All articles with unsourced statements | Articles with unsourced statements since July 2008
posted on 2008-11-06 13:42 gembin 閱讀(713) 評論(1) 編輯 收藏 所屬分類: IoC