在初始化期间以编程方式停止 Java EE 应用程序
Programmatically stop Java EE application during initializaton
是否有任何 Java EE 标准(应用程序服务器交叉兼容)方法如何在初始化期间停止 Java EE 应用程序,即在 @PostConstruct 的 运行 注释方法期间单例@Startup class?
@Singleton
@Startup
public class Initializer {
@PostConstruct
public void checkConfiguration() {
// stop application here
}
}
我正在寻找软方法来停止整个应用程序服务器的应用程序,而不是 System#exit
。
如果您从 @Startup 注释的 @Singleton 中的 @PostConstruct 注释方法中抛出任何类型的 RuntimeException(例如配置错误的 IllegalArgumentException),那么整个应用程序将无法部署。
来自 EJB 3.2 规范的 §4.8.1 "Singleton Session Bean Initialization":
If the Startup annotation appears on the singleton session bean class or if the singleton session bean has been designated via the deployment descriptor as requiring eager initialization, the container must initialize the singleton session bean instance during the application startup sequence. The container must initialize all such startup-time singleton session beans before any external client requests (that is, client requests originating outside of the application) are delivered to any enterprise bean components in the application.
初始化失败不能满足
是否有任何 Java EE 标准(应用程序服务器交叉兼容)方法如何在初始化期间停止 Java EE 应用程序,即在 @PostConstruct 的 运行 注释方法期间单例@Startup class?
@Singleton
@Startup
public class Initializer {
@PostConstruct
public void checkConfiguration() {
// stop application here
}
}
我正在寻找软方法来停止整个应用程序服务器的应用程序,而不是 System#exit
。
如果您从 @Startup 注释的 @Singleton 中的 @PostConstruct 注释方法中抛出任何类型的 RuntimeException(例如配置错误的 IllegalArgumentException),那么整个应用程序将无法部署。
来自 EJB 3.2 规范的 §4.8.1 "Singleton Session Bean Initialization":
If the Startup annotation appears on the singleton session bean class or if the singleton session bean has been designated via the deployment descriptor as requiring eager initialization, the container must initialize the singleton session bean instance during the application startup sequence. The container must initialize all such startup-time singleton session beans before any external client requests (that is, client requests originating outside of the application) are delivered to any enterprise bean components in the application.
初始化失败不能满足