KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > server > web > ShutdownThread


1 /*
2  * ShutdownThread.java
3  *
4  * Created on June 11, 2002, 3:10 AM
5  */

6
7 package com.quikj.server.web;
8
9 import com.quikj.server.framework.*;
10
11 /**
12  *
13  * @author amit
14  */

15 public class ShutdownThread extends Thread JavaDoc
16 {
17     private static boolean shutdownHappened = false;
18     private boolean callExit = false;
19     
20     /** Creates a new instance of ShutdownThread */
21     public ShutdownThread(boolean call_exit)
22     {
23         super();
24         callExit = call_exit;
25     }
26     
27     public ShutdownThread()
28     {
29         this(false);
30     }
31     
32     public void run()
33     {
34         if (shutdownHappened == true) return;
35         shutdownHappened = true;
36         
37         AceLogger.Instance().log(AceLogger.INFORMATIONAL, AceLogger.SYSTEM_LOG,
38         "HTTPApplicationServer.ShutdownThread() -- Shutting down HTTP Application Server");
39         
40         try
41         {
42             // delete all the applications
43
int[] app_list = PluginAppList.Instance().listApplications();
44             
45             for (int i = 0; i < app_list.length; i++)
46             {
47                 PluginAppList.Instance().delete(app_list[i]);
48             }
49                         
50             if (HTTPApplicationServer.getInstance() != null)
51             {
52                 HTTPApplicationServer.getInstance().dispose();
53             }
54             
55         }
56         catch (Exception JavaDoc ex)
57         {
58             ; // ignore
59
}
60         catch (Error JavaDoc ex)
61         {
62             ; // ignore
63
}
64         
65         try
66         {
67             sleep(20000);
68         }
69         catch (InterruptedException JavaDoc ex)
70         {
71             ;
72         }
73         
74         if (callExit == true)
75         {
76             System.exit(0);
77         }
78     }
79  
80     public static void main (String JavaDoc[] args)
81     {
82         ShutdownThread shut = new ShutdownThread();
83         shut.start();
84     }
85 }
86
Popular Tags