- Thread.setDefaultUncaughtExceptionHandler(new org.opendaylight.
- controller.logging.bridge.internal.UncaughtExceptionHandler());
+ UncaughtExceptionHandler handler = DEFAULT_UNCAUGHT_EXCEPTION_POLICY;
+ final String policy = context.getProperty(UNCAUGHT_EXCEPTION_POLICY_PROP);
+ if (policy != null) {
+ try {
+ handler = UncaughtExceptionPolicy.valueOf(policy.toUpperCase());
+ } catch (IllegalArgumentException ex) {
+ log.warn("Invalid policy name \"{}\", defaulting to {}", policy, handler);
+ }
+ }
+ log.trace("Setting uncaught exception policy to {}", handler);
+ Thread.setDefaultUncaughtExceptionHandler(handler);
+
+ /*
+ * Install the Shutdown handler. This will intercept SIGTERM signal and
+ * close the system bundle. This allows for a graceful closing of OSGI
+ * framework.
+ */
+ shutdownHandler = new ShutdownHandler(context);
+ Runtime.getRuntime().addShutdownHook(shutdownHandler);