CDI / Weld SE - @Observes ContainerInitialized 不起作用
我有 Weld SE,以这种方式引导:
WeldContainer weld = new Weld().initialize();
以及以下 bean
@ApplicationScoped
public class EntityManagerStoreImpl implements EntityManagerStore {
static { System.out.println(" AAAAAA EMSI static"); }
public EntityManagerStoreImpl() {
System.out.println(" AAAAAA EMSI constructor");
}
public void init( @Observes ContainerInitialized containerInitialized ) {
System.out.println(" AAAAAA EMSI init");
}
...
}
根据 Weld 文档,应该调用 init()
方法。 但事实并非如此。其他豆子工作正常。
有什么问题吗?
I have Weld SE, bootstraped this way:
WeldContainer weld = new Weld().initialize();
And the following bean
@ApplicationScoped
public class EntityManagerStoreImpl implements EntityManagerStore {
static { System.out.println(" AAAAAA EMSI static"); }
public EntityManagerStoreImpl() {
System.out.println(" AAAAAA EMSI constructor");
}
public void init( @Observes ContainerInitialized containerInitialized ) {
System.out.println(" AAAAAA EMSI init");
}
...
}
According to Weld docs, the init()
method should be called.
But it's not. Other beans are working fine.
What can be wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哦...我应该更仔细地阅读文档。
ContainerInitialized
目前仅从 StartMain 辅助类触发。我不喜欢这样,我希望它从
Weld.initialize()
中触发。所以我创建了 https://issues.jboss.org/browse/WELD-949
(如果您与我分享这个观点,请投票。)
Oh... I should have read the docs more carefuly.
ContainerInitialized
is currently only fired from StartMain helper class.I don't like that, I'd expect it to be fired from
Weld.initialize()
.So I created https://issues.jboss.org/browse/WELD-949
(Pls vote if you share this oppinion with me.)