正确关闭 Java Web 应用程序
我正在寻找一种在应用程序本身内正确关闭(取消部署)Java Web 应用程序的方法。我尝试过 System.exit(),但这不仅关闭了 webApp,而且还弄乱了 Glassfish。
我了解上下文侦听器,我只是想知道如何启动关闭程序。
I'm looking for a way to properly shutdown (Undeploy) an Java Web Application within the application itself. I've tried System.exit(), but this not only shutdown the webApp but also messes up Glassfish.
I know about the contextlistener, I'm just wondering how to start the shutdown procedure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Web 应用程序的部署是应用程序服务器的职责。我确实知道 Glassfish 但其他应用程序的情况如何。服务器(例如 JBoss、Tomcat 等)具有基于 Web 的管理应用程序,可以执行此操作。
如果您想以编程方式从应用程序本身取消部署应用程序,您可以使用 JMX。请参阅 glassfish JMX 实现来了解要调用哪个 bean。但恕我直言,我认为你并不真正需要这个。
Deploying of web applications is the responsibility of application server. I do know how is it in Glassfish but other app. servers (e.g. JBoss, Tomcat etc) have web based management application that allow to do this.
If you want to undeploy application programmatically from the application itself you can use JMX. Refer to the glassfish JMX implementation to know which bean to call. But IMHO I do not think that you really need this.
通常的方法是使用 asadmin undeploy 命令。
该命令的一般形式是:
对于 war-name,使用文字 hello,而不是完整的 hello.war 名称。
对于 hello.war 示例,命令为:
请参阅以下参考文献:
http://docs.oracle.com/cd/E19798-01/821-1757/geyvr/index.html
http://docs.oracle.com/docs /cd/E19798-01/821-1758/undeploy-1/index.html
要以编程方式取消部署,您可以使用 JSR-88,尽管我真的不能找出您想要这样做的原因。请参阅
http://blogs.oracle.com/japod/entry/using_jsr_88_for_web
http://www.jcp.org/en/jsr/detail?id=88
The usual approach is to use the asadmin undeploy command.
The general form for the command is:
For war-name, use the literal hello, not the full hello.war name.
For the hello.war example, the command is:
See the following references:
http://docs.oracle.com/cd/E19798-01/821-1757/geyvr/index.html
http://docs.oracle.com/docs/cd/E19798-01/821-1758/undeploy-1/index.html
To undeploy programmatically, you can use JSR-88 though i cant really see a reason as to why you would want to do this. See
http://blogs.oracle.com/japod/entry/using_jsr_88_for_web
http://www.jcp.org/en/jsr/detail?id=88