EJB module initialization listener
Asked Answered
S

1

7

It's posible to define a listener for EJB 3.0 .jar that is called in the module/context initialization? Similar to the ServerContextListener for web project?

Sidecar answered 24/9, 2010 at 14:57 Comment(0)
B
7

AFAIK, not with EJB 3.0. With EJB 3.1 you can use a Singleton EJB to do so.

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.

Britannia answered 26/9, 2010 at 10:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.