简体   繁体   English

如何在运行时通过JavaEE [7]中的[weld] API实例化CDI bean?

[英]How to instantiate CDI bean at runtime via [weld] API in JavaEE [7]?

I am newbie in CDI and I want to instantiate CDI bean via my XML files, but not via beans.xml. 我是CDI的新手,我想通过XML文件而不是beans.xml实例化CDI bean。 Is it possible and is it normal? 有可能吗,这正常吗? Or maybe I misunderstand CDI concepts? 还是我误解了CDI概念?

I found the answer. 我找到了答案。

A producer method is a method that acts as a source of bean instances. 生产者方法是充当Bean实例源的方法。 The method declaration itself describes the bean and the container invokes the method to obtain an instance of the bean when no instance exists in the specified context. 方法声明本身描述了bean,并且在指定的上下文中不存在任何实例时,容器将调用该方法以获取bean的实例。 A producer method lets the application take full control of the bean instantiation process. 生产者方法使应用程序可以完全控制Bean实例化过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM