简体   繁体   English

仅在ejb中启动特定的bean

[英]Start only specific beans in ejb

This is Java EE 6, I need some key beans from the EJB dependency, which is huge. 这是Java EE 6,我需要EJB依赖项中的一些关键bean,这是巨大的。 It has a lot of @Startup beans, a lot of @Schedule annotations in there which I don't need to be started in my ear. 它里面有很多@Startup bean,里面有很多@Schedule注释,我不需要在我的耳朵里开始。 How it could be achieved? 如何实现?

All the session beans / CDI beans in JavaEE are lazily initialized by default. 默认情况下,JavaEE中的所有会话bean / CDI bean都被延迟了初始化。 Hence unless a bean is accessed, it won't be started. 因此,除非访问bean,否则它将不会启动。 @Startup annotation is for @Singleton session beans to initialize them eagerly. @Startup批注用于@Singleton会话bean,以热切地初始化它们。

During startup, the container scans for all the @Schedule annotations, as such all the timers are created at startup. 在启动过程中,容器扫描所有@Schedule批注,因此所有计时器都在启动时创建。 But the beans which contain the @Schedule method is only initialized the first time the timer is fired. 但是包含@Schedule方法的bean仅在第一次触发计时器时才初始化。

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

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