|
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: Main program for the Java Manager process |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <memory> |
|
19 #include <unistd.h> |
|
20 |
|
21 #include "logger.h" |
|
22 #include "exceptionbase.h" |
|
23 #include "runtimeexception.h" |
|
24 #include "javacommonutils.h" |
|
25 #include "runtimestarterutils.h" |
|
26 #include "jvmstarter.h" |
|
27 |
|
28 using namespace java::runtime; |
|
29 using namespace java::util; |
|
30 |
|
31 int startJvm(int argc, char *argv[]); |
|
32 const wchar_t* const JavaControlPanel_MAIN_CLASS = L"com.nokia.mj.impl.javacontrolpanel.JavaControlPanel"; |
|
33 |
|
34 int main(int argc, char *argv[]) |
|
35 { |
|
36 LOG(EUtils, EInfo, "JavaControlPanel main()"); |
|
37 int result = -1; |
|
38 try |
|
39 { |
|
40 result = startJvm(argc, argv); |
|
41 } |
|
42 catch (RuntimeException& e) |
|
43 { |
|
44 ELOG1(EUtils, "JavaControlPanel main() RuntimeException caught: %s ", |
|
45 e.toString().c_str()); |
|
46 } |
|
47 |
|
48 catch (ExceptionBase& e) |
|
49 { |
|
50 ELOG1(EUtils, "JavaControlPanel main() ExceptionBase caught: %s ", |
|
51 e.toString().c_str()); |
|
52 } |
|
53 |
|
54 catch (std::exception& e) |
|
55 { |
|
56 ELOG1(EUtils, "JavaControlPanel main() Exception %s caught", e.what()); |
|
57 } |
|
58 |
|
59 LOG1(EUtils, EInfo, "JavaControlPanel EXIT = %d", result); |
|
60 return result; |
|
61 } |
|
62 |
|
63 int startJvm(int argc, char *argv[]) |
|
64 { |
|
65 JELOG2(EUtils); |
|
66 |
|
67 // Create instance of RuntimeStarterUtils for thread supervisioning. |
|
68 std::auto_ptr<RuntimeStarterUtils> starterUtils(new RuntimeStarterUtils()); |
|
69 starterUtils->startThreadSupervisor(); |
|
70 |
|
71 // Create starter for starting the JVM |
|
72 std::auto_ptr<JvmStarter> |
|
73 jvm(JvmStarter::getJvmStarterInstance(JvmStarter::CLDC, |
|
74 L"JavaControlPanel")); |
|
75 |
|
76 // Set the debugging features available provided by the captain. |
|
77 // starterUtils->enableDevelopmentFeatures(*jvm.get()); |
|
78 // jvm->enableThreadDumping(); |
|
79 |
|
80 jvm->appendSystemProperty(L"-Dcom.nokia.rt.port=javacontrolpanel"); |
|
81 jvm->setMainClass(JavaControlPanel_MAIN_CLASS); |
|
82 |
|
83 for (int i = 1; i < argc; ++i) |
|
84 { |
|
85 jvm->appendApplicationArgument( |
|
86 JavaCommonUtils::utf8ToWstring(argv[i])); |
|
87 } |
|
88 |
|
89 // Start the JVM. |
|
90 return jvm->startJvm(); |
|
91 } |