GlassfishでJEE5アプリケーションをデプロイ/アンデプロイ/再デプロイするときに、Java関数を自動的にトリガーしてQuartzスケジューラジョブを停止するにはどうすればよいですか。
2160 次
2 に答える
5
を実装ServletContextListener
してフックしcontextDestroyed()
ます。
基本的な例:
public class Config implements ServletContextListener {
public void contextInitialized(ServletContextEvent event) {
// Write code here which should be executed on webapp startup.
}
public void contextDestroyed(ServletContextEvent event) {
// Write code here which should be executed on webapp shutdown.
}
}
にとして登録<listener>
しweb.xml
ます。
<listener>
<listener-class>com.example.Config</listener-class>
</listener>
于 2009-12-07T19:20:09.643 に答える
1
JAVA EE-6+ に到達したら、クラスに @WebListener でアノテーションを付け、そのクラスに ServletContextListener を実装してシャットダウン通知を取得します。web.xml を扱う必要はありません。こちらをご覧ください
于 2013-10-01T16:05:41.547 に答える