1 11 12 package org.eclipse.osgi.framework.debug; 13 14 import java.io.PrintStream ; 15 import java.lang.reflect.*; 16 17 22 public class Debug { 23 26 public static final boolean DEBUG = true; 27 28 31 public static boolean DEBUG_ENABLED = false; 32 33 36 public static boolean DEBUG_GENERAL = false; 40 public static boolean DEBUG_BUNDLE_TIME = false; 44 public static boolean DEBUG_LOADER = false; 48 public static boolean DEBUG_EVENTS = false; 52 public static boolean DEBUG_SERVICES = false; 56 public static boolean DEBUG_PACKAGES = false; 61 public static boolean DEBUG_MANIFEST = false; 65 public static boolean DEBUG_FILTER = false; 69 public static boolean DEBUG_SECURITY = false; 73 public static boolean DEBUG_STARTLEVEL = false; 77 public static boolean DEBUG_PACKAGEADMIN = false; 81 public static boolean DEBUG_PACKAGEADMIN_TIMING = false; 86 public static boolean DEBUG_MESSAGE_BUNDLES = false; 90 public static boolean MONITOR_ACTIVATION = false; 92 95 public static final String ECLIPSE_OSGI = "org.eclipse.osgi"; 99 public static final String OPTION_DEBUG_GENERAL = ECLIPSE_OSGI + "/debug"; 103 public static final String OPTION_DEBUG_BUNDLE_TIME = ECLIPSE_OSGI + "/debug/bundleTime"; 108 public static final String OPTION_DEBUG_LOADER = ECLIPSE_OSGI + "/debug/loader"; 112 public static final String OPTION_DEBUG_EVENTS = ECLIPSE_OSGI + "/debug/events"; 116 public static final String OPTION_DEBUG_SERVICES = ECLIPSE_OSGI + "/debug/services"; 120 public static final String OPTION_DEBUG_PACKAGES = ECLIPSE_OSGI + "/debug/packages"; 124 public static final String OPTION_DEBUG_MANIFEST = ECLIPSE_OSGI + "/debug/manifest"; 128 public static final String OPTION_DEBUG_FILTER = ECLIPSE_OSGI + "/debug/filter"; 132 public static final String OPTION_DEBUG_SECURITY = ECLIPSE_OSGI + "/debug/security"; 136 public static final String OPTION_DEBUG_STARTLEVEL = ECLIPSE_OSGI + "/debug/startlevel"; 140 public static final String OPTION_DEBUG_PACKAGEADMIN = ECLIPSE_OSGI + "/debug/packageadmin"; 144 public static final String OPTION_DEBUG_PACKAGEADMIN_TIMING = ECLIPSE_OSGI + "/debug/packageadmin/timing"; 148 public static final String OPTION_MONITOR_ACTIVATION = ECLIPSE_OSGI + "/monitor/activation"; 152 public static final String OPTION_DEBUG_MESSAGE_BUNDLES = ECLIPSE_OSGI + "/debug/messageBundles"; 154 static { 155 FrameworkDebugOptions dbgOptions = FrameworkDebugOptions.getDefault(); 156 if (dbgOptions != null) { 157 DEBUG_ENABLED = true; 158 DEBUG_GENERAL = dbgOptions.getBooleanOption(OPTION_DEBUG_GENERAL, false); 159 DEBUG_BUNDLE_TIME = dbgOptions.getBooleanOption(OPTION_DEBUG_BUNDLE_TIME, false) || dbgOptions.getBooleanOption("org.eclipse.core.runtime/timing/startup", false); DEBUG_LOADER = dbgOptions.getBooleanOption(OPTION_DEBUG_LOADER, false); 161 DEBUG_EVENTS = dbgOptions.getBooleanOption(OPTION_DEBUG_EVENTS, false); 162 DEBUG_SERVICES = dbgOptions.getBooleanOption(OPTION_DEBUG_SERVICES, false); 163 DEBUG_PACKAGES = dbgOptions.getBooleanOption(OPTION_DEBUG_PACKAGES, false); 164 DEBUG_MANIFEST = dbgOptions.getBooleanOption(OPTION_DEBUG_MANIFEST, false); 165 DEBUG_FILTER = dbgOptions.getBooleanOption(OPTION_DEBUG_FILTER, false); 166 DEBUG_SECURITY = dbgOptions.getBooleanOption(OPTION_DEBUG_SECURITY, false); 167 DEBUG_STARTLEVEL = dbgOptions.getBooleanOption(OPTION_DEBUG_STARTLEVEL, false); 168 DEBUG_PACKAGEADMIN = dbgOptions.getBooleanOption(OPTION_DEBUG_PACKAGEADMIN, false); 169 DEBUG_PACKAGEADMIN_TIMING = dbgOptions.getBooleanOption(OPTION_DEBUG_PACKAGEADMIN_TIMING, false) || dbgOptions.getBooleanOption("org.eclipse.core.runtime/debug", false); DEBUG_MESSAGE_BUNDLES = dbgOptions.getBooleanOption(OPTION_DEBUG_MESSAGE_BUNDLES, false); 171 MONITOR_ACTIVATION = dbgOptions.getBooleanOption(OPTION_MONITOR_ACTIVATION, false); 172 } 173 } 174 175 178 public static PrintStream out = System.out; 179 180 184 public static void print(boolean x) { 185 out.print(x); 186 } 187 188 192 public static void print(char x) { 193 out.print(x); 194 } 195 196 200 public static void print(int x) { 201 out.print(x); 202 } 203 204 208 public static void print(long x) { 209 out.print(x); 210 } 211 212 216 public static void print(float x) { 217 out.print(x); 218 } 219 220 224 public static void print(double x) { 225 out.print(x); 226 } 227 228 232 public static void print(char x[]) { 233 out.print(x); 234 } 235 236 240 public static void print(String x) { 241 out.print(x); 242 } 243 244 248 public static void print(Object x) { 249 out.print(x); 250 } 251 252 256 public static void println(boolean x) { 257 out.println(x); 258 } 259 260 264 public static void println(char x) { 265 out.println(x); 266 } 267 268 272 public static void println(int x) { 273 out.println(x); 274 } 275 276 280 public static void println(long x) { 281 out.println(x); 282 } 283 284 288 public static void println(float x) { 289 out.println(x); 290 } 291 292 296 public static void println(double x) { 297 out.println(x); 298 } 299 300 304 public static void println(char x[]) { 305 out.println(x); 306 } 307 308 312 public static void println(String x) { 313 out.println(x); 314 } 315 316 320 public static void println(Object x) { 321 out.println(x); 322 } 323 324 328 public static void printStackTrace(Throwable t) { 329 if (t == null) 330 return; 331 t.printStackTrace(out); 332 333 Method[] methods = t.getClass().getMethods(); 334 335 int size = methods.length; 336 Class throwable = Throwable .class; 337 338 for (int i = 0; i < size; i++) { 339 Method method = methods[i]; 340 341 if (Modifier.isPublic(method.getModifiers()) && method.getName().startsWith("get") && throwable.isAssignableFrom(method.getReturnType()) && (method.getParameterTypes().length == 0)) { try { 343 Throwable nested = (Throwable ) method.invoke(t, null); 344 345 if ((nested != null) && (nested != t)) { 346 out.println("Nested Exception:"); printStackTrace(nested); 348 } 349 } catch (IllegalAccessException e) { 350 } catch (InvocationTargetException e) { 351 } 352 } 353 } 354 } 355 356 } 357 | Popular Tags |