IoC implementation Strategies

Expert one on one J2EE development without EJB:P-128-9

IoC Implementation Strategies
IoC的实现策略

IoC is a broad concept that can be implemented in different ways. There are two main types:
IoC是一个很大的概念,它可以通过不同的方式来实现。最常见的方式有两种:

Dependency Lookup: The container provides callbacks to components, and a lookup context.This is the EJB and Apache Avalon approach. It leaves the onus on each component to use container APIs to look up resources and collaborators. The Inversion of Control is limited to the
container invoking callback methods that application code can use to obtain resources.
依赖查找:容器为组件提供回调接口和一个查找上下文。EJB和Apache Avalon采用的这种方式。这样一来,组件就必须自己使用容器提供的API来查找资源和协作对象,控制反转被限定在容器引用回调方法,由这些方法的代码可以实现获取资源。

Dependency Injection: Components do no look up; they provide plain Java methods enabling the container to resolve dependencies. The container is wholly responsible for wiring up components, passing resolved objects in to JavaBean properties or constructors. Use of JavaBean
properties is called Setter Injection; use of constructor arguments is called Constructor Injection.
依赖注入:组件不自己进行查找,而是提供一般的java方法让容器去解决依赖关系。容器全权负责组件的装配,把符合依赖关系的对象通过javabean属性或构造子传递给需要的对象,通过javabean属性注射依赖的做法叫做Setter注入;通过构造子参数的做法叫做构造子注入。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值