00001 package org.openmobileis.services.servlet;
00002
00003 import javax.servlet.ServletException;
00004 import javax.servlet.http.HttpServlet;
00005 import javax.servlet.http.HttpServletRequest;
00006 import javax.servlet.http.HttpServletResponse;
00007
00008 import org.openmobileis.common.util.log.LogManager;
00009
00018 public class ShutdownServlet extends HttpServlet {
00019 static final long serialVersionUID = 5521257935120563452L;
00020
00021 public ShutdownServlet() {
00022 System.out.println("ShutdownServlet init");
00023 }
00024
00025
00026 public void service( HttpServletRequest req, HttpServletResponse res ) throws ServletException, java.io.IOException {
00027
00028 res.setContentType( "text/html" );
00029
00030 res.getOutputStream().write("<HTML><BODY>Vous pouvez fermer la fenêtre</BODY></HTML>".getBytes());
00031 this.finalizeBeforeShutdown();
00032 Runnable toShut = new Runnable(){
00033 public void run() {
00034 try {
00035
00036
00037 Thread.currentThread().sleep(2000);
00038
00039
00040 System.exit(1);
00041 } catch (Exception ex) {
00042 LogManager.traceError(0, ex);
00043 }
00044 }
00045 };
00046
00047 Thread th = new Thread(toShut);
00048 th.start();
00049
00050 }
00051
00052 protected void finalizeBeforeShutdown() {}
00053 }