As of EJB 3.1, singleton beans can be notified of module start and stop:
@Singleton
@Startup
public class StartupBean {
@PostConstruct
private void postConstruct() { /* ... */ }
@PreDestroy
private void preDestroy() { /* ... */ }
}
Prior to EJB 3.1, there is no standard, EJB-only solution. I'd suggest adding a WAR to your EAR and using a servlet-context-listener.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…