This is known as constructor injection.
这称为构造器注入。
Constructor injection USES a constructor to determine what type of concrete object to return.
构造函数注入利用构造函数判断要返回的具体对象类型。
Constructor injection in Spring lets you inject your dependencies through class constructors.
Spring中的构造函数注入允许您通过类构造函数注入依赖关系。
Listing 5 shows a GBean that's defined to use constructor injection to provide a Customer reference.
清单5显示的GBean被定义成使用构造函数注入来提供Customer引用。
HiveMind users typically prefer setter injection, but the container also supports constructor injection.
HiveMind用户通常优先选择setter注入,但该容器还支持构造函数注入。
Two major schools of thought revolve around how to perform DI: constructor injection and setter injection.
围绕着如何执行DI,主要有两派思想:构造函数注入和setter注入。
PicoContainer's prevailing usage model is constructor injection, although it also supports setter injection.
PicoContainer 流行的使用模型是构造函数注入,但它也支持setter 注入。
However, I prefer constructor injection, as do Guice's authors. Here's a quick analysis of the three styles.
不过,像Guice的作者一样,我更喜欢构造函数注入。
According to the Guice best practices guide, constructor injection is the preferred way to ask for your dependencies.
根据Guice的最佳实践指南,构造函数注入是询问依赖项的首选方式。
The feature pack for SCA currently supports only constructor injection when the Spring bean has a single constructor.
当Springbean拥有单个构造函数时,这个针对sca的特性包目前只支持构造函数注入。
You can also use it if you have a superclass that needs some dependencies. (Constructor injection makes this difficult.)
如果您有一个需要某些依赖项的超类,也可以使用方法注入(构造函数注入会使这种情况变得很复杂)。
Next, you see an example of constructor injection and how Geronimo's deployment plans define how the container injects code.
接下来,将看到构造函数注入的示例,以及Geronimo的部署计划定义容器注入代码的方式。
OpenEJB will also support constructor injection, which enables the container to provide various classes and objects at run time.
OpenEJB还将支持构造器注入,从而使得容器可以在运行时提供各种类和对象。
This behavior is referred to in the DI world as constructor injection, because the instance is passed through one of the constructors.
这个行为在DI世界中称作构造函数注入,因为实例是通过一个构造函数传递的。
Many proponents of DI prefer constructor injection, because it means that the injected class never exists in a state where its dependencies aren't present.
许多DI的支持者愿意采用构造函数注入,因为这意味着注入的类永远不会出现依赖项不存在的情况。
You should define your bean definition as shown in Listing 7. Using implicit sca references and properties are not supported for constructor injection in Tuscany.
您应该像清单7所示的那样定义bean。在Tuscany中,不支持为构造函数使用隐式sca引用和属性。
Again, these setters are framework induced boilerplate code. Wouldn’t it be nice if they could be avoided without the need to use Constructor injection everywhere?
毫无疑问,这些setter是框架所需的样板代码,如果不使用构造器注入也能避免这一点岂不美哉?
As explained in the first article of this series, constructor injection implies that the framework supplies constructor parameters required by the class upon instantiation.
正如在本系列的第一篇文章中解释过的,构造函数注入表明框架会提供类在初始化时需要的构造函数参数。
The EJB 3.0 specification talks about public field injection and setter injection, but constructor injection will enable you to avoid creating setters for values you don't expect to change.
EJB 3.0规范谈到了公共字段注入和setter注入,但构造器注入将使您可以避免为预期不会更改的值创建setter。
This instantiation involves the default constructor for the class being called, with the injection of dependencies happening afterwards.
这种实例化涉及到要调用的类的默认构造函数,随后还要注入依赖关系。
While using this approach we have to remember that this mechanism supports only accessor-based injection, constructor argument based injection is not supported.
在使用该方法时,我们必须记住该机制只支持访问器注入,不支持基于构造函数参数的注入。
Spring supports three types of dependency injection — setter, constructor, and method injection — but overall, the prevailing model is setter injection.
Spring支持三种依赖注入——setter、构造函数和方法注入——但总的来说,最流行的模型是setter注入。
Unity is a lightweight, extensible dependency injection container with support for constructor, property, and method call injection.
Unity是一个轻量级,可扩展的依赖注入容器,支持构造函数,属性和方法调用注入。
Unity is a lightweight, extensible dependency injection container with support for constructor, property, and method call injection.
Unity是一个轻量级,可扩展的依赖注入容器,支持构造函数,属性和方法调用注入。
应用推荐