Eager / auto loading of EJB / load EJB on startup (on JBoss)

后端 未结 2 1681
心在旅途
心在旅途 2020-11-28 09:12

EJBs seem to be loaded lazily - whenever accessed.

However, I want to initialize them eagerly - i.e. whenever the container starts-up. How is this achieved (in JBoss

2条回答
  •  一个人的身影
    2020-11-28 10:11

    According to Adam Bien's Real World Java EE Patterns - Rethinking Best Practices (see a summary of the patterns) and the Service Starter pattern, it is indeed as bkail suggests

    • with Java EE 6 = EJB 3.1 use @Singleton with @Startup (and perhaps also with @DependsOn)
    • prior to that the only standard and portable way is to use the Servlet API, e.g. a HttpServlet starting the EJBs in its init() method and load-on-startup set to 1 in web.xml.

提交回复
热议问题