在启动时(在JBoss上)急切/自动加载EJB / load EJB [英] Eager / auto loading of EJB / load EJB on startup (on JBoss)
本文介绍了在启动时(在JBoss上)急切/自动加载EJB / load EJB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
EJB似乎是懒惰地加载 - 无论何时访问。
EJBs seem to be loaded lazily - whenever accessed.
但是,我想急切地初始化它们 - 即每当容器启动时。如何实现(特别是在JBoss中)
However, I want to initialize them eagerly - i.e. whenever the container starts-up. How is this achieved (in JBoss in particular)
本主题提供了一些提示,但不太令人满意。
This topic gives some hints, but isn't quite satisfactory.
推荐答案
从EJB 3.1开始,单身人士可以通知bean模块启动和停止:
As of EJB 3.1, singleton beans can be notified of module start and stop:
@Singleton
@Startup
public class StartupBean {
@PostConstruct
private void postConstruct() { /* ... */ }
@PreDestroy
private void preDestroy() { /* ... */ }
}
在EJB 3.1之前,没有标准的,仅限EJB的解决方案。我建议在你的EAR中添加一个WAR并使用servlet-context-listener。
Prior to EJB 3.1, there is no standard, EJB-only solution. I'd suggest adding a WAR to your EAR and using a servlet-context-listener.
这篇关于在启动时(在JBoss上)急切/自动加载EJB / load EJB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文