37 private static final String PORTCLASS_PROPERTY_NAME = "com.nokia.jvm.port"; |
37 private static final String PORTCLASS_PROPERTY_NAME = "com.nokia.jvm.port"; |
38 |
38 |
39 private static final String PORTCLASS_PACKAGE = "com.nokia.mj.impl.rt."; |
39 private static final String PORTCLASS_PACKAGE = "com.nokia.mj.impl.rt."; |
40 |
40 |
41 /** |
41 /** |
42 * When the class is loaded it will try to create the VM porting class |
42 * When the getInstace() is first called it will be tried to create the |
43 * defined in the system property PORTCLASS_PROPERTY_NAME |
43 * VM porting class defined in the system property PORTCLASS_PROPERTY_NAME. |
44 */ |
44 * The package visiblity is set to protected for unit testing purposes. |
45 private static JvmPort sInstance = null; |
45 */ |
|
46 protected static JvmPort sInstance = null; |
46 |
47 |
47 /** |
48 /** |
48 * A reference to object containing properties. In CLDC it is Hashtable, |
49 * A reference to object containing properties. In CLDC it is Hashtable, |
49 * otherwise it is Properties. |
50 * otherwise it is Properties. |
50 */ |
51 * The package visiblity is set to protected for unit testing purposes. |
51 private static DynamicProperty mPropertiesContainer; |
52 */ |
|
53 protected static DynamicProperty mPropertiesContainer; |
52 |
54 |
53 protected JvmPort() |
55 protected JvmPort() |
54 { |
56 { |
55 } |
57 } |
56 |
58 |
57 /** |
59 /** |
58 * Static initializer |
60 * Static initializer |
59 */ |
61 */ |
60 static |
62 private static synchronized void loadImpl() |
61 { |
63 { |
|
64 if (sInstance != null) |
|
65 { |
|
66 return; |
|
67 } |
62 String vmPortClass = System.getProperty(PORTCLASS_PROPERTY_NAME); |
68 String vmPortClass = System.getProperty(PORTCLASS_PROPERTY_NAME); |
63 if (vmPortClass == null) |
69 if (vmPortClass == null) |
64 { |
70 { |
65 throw new RuntimeException("Not able to load VM port class since " |
71 throw new RuntimeException("Not able to load VM port class since " |
66 + PORTCLASS_PROPERTY_NAME + |
72 + PORTCLASS_PROPERTY_NAME + |
72 Class clazz = Class.forName(vmPortClass); |
78 Class clazz = Class.forName(vmPortClass); |
73 sInstance = (JvmPort)clazz.newInstance(); |
79 sInstance = (JvmPort)clazz.newInstance(); |
74 } |
80 } |
75 catch (Exception e) |
81 catch (Exception e) |
76 { |
82 { |
77 String errTxt = "Not able to instantiate class " + |
83 String errTxt = "Not able to instantiate class " + vmPortClass; |
78 vmPortClass + "."; |
|
79 Logger.ELOG(Logger.EUtils, errTxt, e); |
84 Logger.ELOG(Logger.EUtils, errTxt, e); |
80 throw new RuntimeException(errTxt); |
85 throw new RuntimeException(errTxt); |
81 } |
86 } |
82 } |
87 } |
83 |
88 |
123 * setThreadAsDaemon((java.lang.Thread, boolean)). |
132 * setThreadAsDaemon((java.lang.Thread, boolean)). |
124 */ |
133 */ |
125 public abstract void setThreadAsDaemon(Thread Thread, |
134 public abstract void setThreadAsDaemon(Thread Thread, |
126 boolean daemon) |
135 boolean daemon) |
127 throws IllegalThreadStateException, |
136 throws IllegalThreadStateException, |
128 SecurityException; |
137 SecurityException; |
129 |
138 |
130 |
139 |
131 /** |
140 /** |
132 * @see com.nokia.mj.impl.rt.support.Jvm# |
141 * @see com.nokia.mj.impl.rt.support.Jvm# |
133 * getResourceAsNativeMemory(java.lang.String, java.lang.String). |
142 * getResourceAsNativeMemory(java.lang.String, java.lang.String). |