1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.mj.impl.javacontrolpanel; |
|
19 |
|
20 import com.nokia.mj.impl.utils.Logger; |
|
21 import com.nokia.mj.impl.rt.support.JvmInternal; |
|
22 import com.nokia.mj.impl.rt.support.ThreadEventListener; |
|
23 |
|
24 class JavaControlPanel |
|
25 { |
|
26 /** |
|
27 * JavaControlPanel main program. |
|
28 * |
|
29 * @param aArgs command line arguments |
|
30 */ |
|
31 public static void main(String[] aArgs) |
|
32 { |
|
33 Logger.ILOG(Logger.EUtils, "JavaControlPanel.main starts"); |
|
34 int exitCode = 0; |
|
35 |
|
36 try |
|
37 { |
|
38 JvmInternal.setThreadEventListener(new ThreadEventListener() |
|
39 { |
|
40 public void threadStarting(Thread newThread, Thread parentThread) {} |
|
41 public void threadDied(Thread thread) {} |
|
42 public void uncaughtException(Thread thread, Throwable throwable) |
|
43 { |
|
44 String threadName = null; |
|
45 if (thread != null) |
|
46 { |
|
47 threadName = thread.getName(); |
|
48 } |
|
49 Logger.ELOG(Logger.EUtils, "Unhandled exception in " + |
|
50 threadName, throwable); |
|
51 } |
|
52 }); |
|
53 exitCode = mainWithResult(aArgs); |
|
54 } |
|
55 catch (Throwable t) |
|
56 { |
|
57 Logger.ELOG(Logger.EUtils, "Unhandled exception in main", t); |
|
58 exitCode = -1; |
|
59 } |
|
60 |
|
61 Logger.ILOG(Logger.EUtils, "JavaControlPanel.main exits with code " + exitCode); |
|
62 System.exit(exitCode); |
|
63 } |
|
64 |
|
65 /** |
|
66 * JavaControlPanel main program which returns error code indicating |
|
67 * operation result. |
|
68 * |
|
69 * @param aArgs command line arguments |
|
70 * @return error code indicating operation result |
|
71 */ |
|
72 public static int mainWithResult(String[] aArgs) |
|
73 { |
|
74 if (aArgs.length == 0) |
|
75 { |
|
76 JavaControlPanelUi ui = new JavaControlPanelUi(); |
|
77 ui.show(); |
|
78 } |
|
79 else |
|
80 { |
|
81 Logger.WLOG(Logger.EUtils, "JavaControlPanel making thread dump and exiting"); |
|
82 new JavaCaptain().doThreadDump(); |
|
83 } |
|
84 return 0; |
|
85 } |
|
86 |
|
87 } |
|