|
1 /* |
|
2 * Copyright (c) 2009 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: Utilities for starting the Java runtime. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef RUNTIMESTARTERUTILS_H |
|
20 #define RUNTIMESTARTERUTILS_H |
|
21 |
|
22 #include <string> |
|
23 #include "javaoslayer.h" |
|
24 #include "jvmstarter.h" |
|
25 |
|
26 namespace java // codescanner::namespace |
|
27 { |
|
28 |
|
29 namespace comms // codescanner::namespace |
|
30 { |
|
31 class CommsClientEndpoint; |
|
32 } |
|
33 |
|
34 namespace runtime // codescanner::namespace |
|
35 { |
|
36 |
|
37 class OsThreadSupervisor; |
|
38 class DevelopmentFeaturesListener; |
|
39 |
|
40 /** |
|
41 * This class is responsible for providing utilies related to starting |
|
42 * the javaruntime. |
|
43 */ |
|
44 OS_NONSHARABLE_CLASS(RuntimeStarterUtils) |
|
45 { |
|
46 public: |
|
47 |
|
48 /** |
|
49 * Constructor of the RuntimeStarterUtils. |
|
50 */ |
|
51 OS_IMPORT RuntimeStarterUtils(); |
|
52 |
|
53 /** |
|
54 * Destructor of the RuntimeStarterUtils. Will destroy the instance of |
|
55 * comms client endpoint if has been created by this object. The class |
|
56 * is not meant to be inherited, so destructor can be non virtual. |
|
57 */ |
|
58 OS_IMPORT ~RuntimeStarterUtils(); |
|
59 |
|
60 /** |
|
61 * Creates a platform dependent thread supervisor for detecting thread |
|
62 * panics. When the thread supervisioning is enabled, any panicing thread |
|
63 * belonging to this process will lead to termination of the process. |
|
64 * At least in Symbian it is important to enable this feature. Panic of |
|
65 * one thread doesn't automatically lead to termination of the whole |
|
66 * process. |
|
67 * <p> |
|
68 * The lifetime of the supervisor is tight to existence of instance of |
|
69 * this class. Once the object is destroyed, alos the supervisor is |
|
70 * terminated. |
|
71 * @param tryThreadDumping Whether to try to do thread dump in panic case. |
|
72 * Might cause another panic. |
|
73 * @throws std::exception on error cases. |
|
74 */ |
|
75 OS_IMPORT void startThreadSupervisor(bool tryThreadDumping = false); |
|
76 |
|
77 /** |
|
78 * This method will enable various kind of development features - like |
|
79 * debugging, profiling and thread dumping. At the moment all these |
|
80 * development features are to some extent controlled by Java Captain. |
|
81 * This is natural to MIDP runtime but a little problematic to non-managed |
|
82 * runtimes like Installer and TCK runner. Captain is not aware of these |
|
83 * non-managed runtimes. |
|
84 * <p> |
|
85 * This method will make a comms connection to Java Captain if it doesn't. |
|
86 * exist. For determining the existence it will search if a named comms |
|
87 * client endpoint is already created with name "javacaptain". If it |
|
88 * doesn't, then a new one is created. The endpoint is used when |
|
89 * generating thread dumps. Java Captain will deliver dump message to |
|
90 * all the running Java process that it is aware of. |
|
91 * <p> |
|
92 * Internally this method will ask from Java Captain if there are some |
|
93 * extra arguments to be provided to the JVM (if onlyThreadDump is set |
|
94 * to false). Those parameters can be |
|
95 * related e.g to debugging, profiling or something else. |
|
96 * <p> |
|
97 * The method will add a new lister to listen to thread dump messages from |
|
98 * Java Captain. |
|
99 * <p> |
|
100 * Note! If this method needs to create a new instance of comms client |
|
101 * endpoint, the exitence of endpoint is tight to existence of instance |
|
102 * of RuntimeUtils object. I.e. the endpoint is destroyd when the |
|
103 * destructor is called. |
|
104 * @param jvmStarter. User must provide a valid reference to JvmStarter. |
|
105 * This method will append certain JVM arguments |
|
106 * if some development features are set on. The |
|
107 * same JvmStarter must be used for starting the JVM. |
|
108 * @param askForArgs. If set to false, only thread dumping listening |
|
109 * is enabled and no message is sent to Captain. |
|
110 * @param applicationArgs. If askForArgs is true, this paramater must |
|
111 * point to a wstring. The arguments for the |
|
112 * application to be started will be returned in |
|
113 * the wstring. |
|
114 */ |
|
115 OS_IMPORT void enableDevelopmentFeatures(JvmStarter& jvmStarter, |
|
116 bool askForArgs = false, |
|
117 std::wstring *applicationArgs = NULL); |
|
118 /** |
|
119 * Finds the add-on JSRs from platform dependent repository. |
|
120 * @param extendedBootClassPath a refernce to wstring where the method can store |
|
121 * the boot classpath. If the there are no add-on JSRs, |
|
122 * this will be empty wstring. |
|
123 */ |
|
124 OS_IMPORT void getExtBootClassPath(std::wstring& extendedBootClassPath); |
|
125 |
|
126 private: // Classes |
|
127 |
|
128 private: // Methods. |
|
129 |
|
130 /* |
|
131 * No copy constructor allowed. |
|
132 */ |
|
133 RuntimeStarterUtils(const RuntimeStarterUtils&); |
|
134 |
|
135 /* |
|
136 * No Assignment operator allowed. |
|
137 */ |
|
138 RuntimeStarterUtils& operator= (const RuntimeStarterUtils&); |
|
139 |
|
140 void addRuntimeArguments(const std::wstring& aRuntimeArgs, JvmStarter& jvmStarter); |
|
141 |
|
142 private: // Member variables. |
|
143 java::comms::CommsClientEndpoint* mComms; |
|
144 OsThreadSupervisor* mSupervisor; |
|
145 DevelopmentFeaturesListener* mListener; |
|
146 }; |
|
147 |
|
148 } // end namespace runtime |
|
149 } // end namespace java |
|
150 |
|
151 |
|
152 #endif // RUNTIMESTARTERUTILS_H |