简体   繁体   English

EJB模块初始化侦听器

[英]EJB module initialization listener

It's posible to define a listener for EJB 3.0 .jar that is called in the module/context initialization? 为模块/上下文初始化中调用的EJB 3.0 .jar定义一个侦听器是可行的吗? Similar to the ServerContextListener for web project? 类似于Web项目的ServerContextListener?

AFAIK, not with EJB 3.0. AFAIK,而不是EJB 3.0。 With EJB 3.1 you can use a Singleton EJB to do so. 使用EJB 3.1,您可以使用Singleton EJB来执行此操作。

From Application Startup / Shutdown Callbacks : 应用程序启动/关闭回调

   1:  @Startup
   2:  @Singleton
   3:  public class FooBean {
   4:   
   5:    @PostConstruct 
   6:    void atStartup() { ... }
   7:   
   8:    @PreDestroy
   9:    void atShutdown() { ... }
  10:   
  11:  }

See this answer for more details. 有关详细信息,请参阅此答案

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

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