简体   繁体   English

正确关闭Java Web应用程序

[英]Proper shutdown Java Web Application

I'm looking for a way to properly shutdown (Undeploy) an Java Web Application within the application itself. 我正在寻找一种在应用程序本身内部正确关闭(取消部署)Java Web应用程序的方法。 I've tried System.exit(), but this not only shutdown the webApp but also messes up Glassfish. 我已经尝试过System.exit(),但这不仅关闭了WebApp,而且还弄乱了Glassfish。

I know about the contextlistener, I'm just wondering how to start the shutdown procedure. 我了解contextlistener,我只是想知道如何启动关闭程序。

Deploying of web applications is the responsibility of application server. Web应用程序的部署是应用程序服务器的责任。 I do know how is it in Glassfish but other app. 我确实知道在Glassfish中但在其他应用程序中情况如何。 servers (eg JBoss, Tomcat etc) have web based management application that allow to do this. 服务器(例如JBoss,Tomcat等)具有基于Web的管理应用程序,可以执行此操作。

If you want to undeploy application programmatically from the application itself you can use JMX. 如果要以编程方式从应用程序本身取消部署应用程序,则可以使用JMX。 Refer to the glassfish JMX implementation to know which bean to call. 请参阅glassfish JMX实现以了解要调用哪个bean。 But IMHO I do not think that you really need this. 但是恕我直言,我认为您并不是真的需要这个。

The usual approach is to use the asadmin undeploy command. 通常的方法是使用asadmin undeploy命令。

The general form for the command is: 该命令的一般形式为:

as-install/bin/asadmin undeploy war-name

For war-name, use the literal hello, not the full hello.war name. 对于war-name,请使用文字hello,而不是完整的hello.war名称。

For the hello.war example, the command is: 对于hello.war示例,命令为:

as-install/bin/asadmin undeploy hello

See the following references: 请参阅以下参考:

http://docs.oracle.com/cd/E19798-01/821-1757/geyvr/index.html 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 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. 要以编程方式取消部署,可以使用JSR-88,尽管我真的看不到为什么要执行此操作的原因。 See 看到

http://blogs.oracle.com/japod/entry/using_jsr_88_for_web http://blogs.oracle.com/japod/entry/using_jsr_88_for_web

http://www.jcp.org/en/jsr/detail?id=88 http://www.jcp.org/en/jsr/detail?id=88

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM