X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2FService.java;h=9dcea49d2d6199cad72b9696191de85ecbd69f53;hb=def1b847ee067994c32f49107e22d3c04eac2b0e;hp=ef65d02cf14f46b35c805dc5ca5a8574c8136d63;hpb=dea32138f55d1c80f75515793ed15be0e89e6d61;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.init/src/org/argeo/init/Service.java b/org.argeo.init/src/org/argeo/init/Service.java index ef65d02cf..9dcea49d2 100644 --- a/org.argeo.init/src/org/argeo/init/Service.java +++ b/org.argeo.init/src/org/argeo/init/Service.java @@ -25,14 +25,15 @@ public class Service implements Runnable, AutoCloseable { public static void main(String[] args) { long pid = ProcessHandle.current().pid(); - log.log(Logger.Level.DEBUG, "Starting with PID " + pid); + log.log(Logger.Level.DEBUG, "Argeo Init starting with PID " + pid); // shutdown on exit Runtime.getRuntime().addShutdownHook(new Thread(() -> { try { if (Service.runtimeContext != null) { +// System.out.println("Argeo Init stopping with PID " + pid); Service.runtimeContext.close(); - //Service.runtimeContext.waitForStop(0); + Service.runtimeContext.waitForStop(0); } } catch (Exception e) { e.printStackTrace(); @@ -47,21 +48,26 @@ public class Service implements Runnable, AutoCloseable { // log.log(Logger.Level.DEBUG, key + "=" + System.getProperty(key.toString())); // } try { - try (OsgiRuntimeContext osgiRuntimeContext = new OsgiRuntimeContext((Map) config)) { + try { + OsgiRuntimeContext osgiRuntimeContext = new OsgiRuntimeContext((Map) config); osgiRuntimeContext.run(); Service.runtimeContext = osgiRuntimeContext; Service.runtimeContext.waitForStop(0); } catch (NoClassDefFoundError e) { - try (StaticRuntimeContext staticRuntimeContext = new StaticRuntimeContext((Map) config)) { - staticRuntimeContext.run(); - Service.runtimeContext = staticRuntimeContext; - Service.runtimeContext.waitForStop(0); - } + StaticRuntimeContext staticRuntimeContext = new StaticRuntimeContext((Map) config); + staticRuntimeContext.run(); + Service.runtimeContext = staticRuntimeContext; + Service.runtimeContext.waitForStop(0); } } catch (Exception e) { e.printStackTrace(); System.exit(1); } + log.log(Logger.Level.DEBUG, "Argeo Init stopped with PID " + pid); } + + public static RuntimeContext getRuntimeContext() { + return runtimeContext; + } }