AFAIK,而不是EJB 3.0.使用EJB 3.1,您可以使用Singleton EJB来执行此操作.
1: @Startup
2: @Singleton
3: public class FooBean {
4:
5: @PostConstruct
6: void atStartup() { ... }
7:
8: @PreDestroy
9: void atShutdown() { ... }
10:
11: }
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅此答案.