X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2Fosgi%2FOsgiBoot.java;h=223effb549c39799d6a34c2279f93cbe736ba0d7;hb=e57ee18ac7b8cfd2bdf4b2e56a65275ce24732b3;hp=8573615ed11a7a528f266e006e4f0457941fed5a;hpb=6bf0278e427c0a9fe9d922fe19593b89892cb03e;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.init/src/org/argeo/init/osgi/OsgiBoot.java b/org.argeo.init/src/org/argeo/init/osgi/OsgiBoot.java index 8573615ed..223effb54 100644 --- a/org.argeo.init/src/org/argeo/init/osgi/OsgiBoot.java +++ b/org.argeo.init/src/org/argeo/init/osgi/OsgiBoot.java @@ -19,6 +19,7 @@ import java.util.Set; import java.util.SortedMap; import java.util.StringTokenizer; import java.util.TreeMap; +import java.util.concurrent.ForkJoinPool; import org.argeo.init.a2.A2Source; import org.argeo.init.a2.ProvisioningManager; @@ -104,6 +105,13 @@ public class OsgiBoot implements OsgiBootConstants { A2Source.SCHEME_A2 + "://" + homePath.toString() + "/.local/share/a2" + queryPart); provisioningManager.registerSource(A2Source.SCHEME_A2 + ":///usr/local/share/a2" + queryPart); provisioningManager.registerSource(A2Source.SCHEME_A2 + ":///usr/share/a2" + queryPart); + } else if (source.trim().equals(A2Source.DEFAULT_A2_REFERENCE_URI)) { + if (Files.exists(homePath)) + provisioningManager.registerSource(A2Source.SCHEME_A2_REFERENCE + "://" + homePath.toString() + + "/.local/share/a2" + queryPart); + provisioningManager + .registerSource(A2Source.SCHEME_A2_REFERENCE + ":///usr/local/share/a2" + queryPart); + provisioningManager.registerSource(A2Source.SCHEME_A2_REFERENCE + ":///usr/share/a2" + queryPart); } else { provisioningManager.registerSource(source + queryPart); } @@ -350,6 +358,14 @@ public class OsgiBoot implements OsgiBootConstants { // default and active start levels from System properties Integer defaultStartLevel = Integer.parseInt(getProperty(PROP_OSGI_BUNDLES_DEFAULTSTARTLEVEL, "4")); Integer activeStartLevel = Integer.parseInt(getProperty(PROP_OSGI_STARTLEVEL, "6")); + if (OsgiBootUtils.isDebug()) { + OsgiBootUtils.debug("OSGi default start level: " + + getProperty(PROP_OSGI_BUNDLES_DEFAULTSTARTLEVEL, "") + ", using " + defaultStartLevel); + OsgiBootUtils.debug("OSGi active start level: " + getProperty(PROP_OSGI_STARTLEVEL, "") + + ", using " + activeStartLevel); + OsgiBootUtils.debug("Framework start level: " + frameworkStartLevel.getStartLevel() + " (initial: " + + frameworkStartLevel.getInitialBundleStartLevel() + ")"); + } SortedMap> startLevels = new TreeMap>(); computeStartLevels(startLevels, properties, defaultStartLevel); @@ -376,12 +392,21 @@ public class OsgiBoot implements OsgiBootConstants { } } } - frameworkStartLevel.setStartLevel(activeStartLevel, (FrameworkEvent event) -> { - if (OsgiBootUtils.isDebug()) - OsgiBootUtils.debug("Framework event: " + event); - int initialStartLevel = frameworkStartLevel.getInitialBundleStartLevel(); - int startLevel = frameworkStartLevel.getStartLevel(); - OsgiBootUtils.debug("Framework start level: " + startLevel + " (initial: " + initialStartLevel + ")"); + + if (OsgiBootUtils.isDebug()) + OsgiBootUtils.debug("About to set framework start level to " + activeStartLevel + " ..."); + + // Start the framework asynchronously + ForkJoinPool.commonPool().execute(() -> { + frameworkStartLevel.setStartLevel(activeStartLevel, (FrameworkEvent event) -> { + if (OsgiBootUtils.isDebug()) + OsgiBootUtils.debug("Framework event: " + event); + int initialStartLevel = frameworkStartLevel.getInitialBundleStartLevel(); + int startLevel = frameworkStartLevel.getStartLevel(); + if (OsgiBootUtils.isDebug()) + OsgiBootUtils + .debug("Framework start level: " + startLevel + " (initial: " + initialStartLevel + ")"); + }); }); } @@ -659,6 +684,7 @@ public class OsgiBoot implements OsgiBootConstants { private void refreshFramework() { Bundle systemBundle = bundleContext.getBundle(0); FrameworkWiring frameworkWiring = systemBundle.adapt(FrameworkWiring.class); + // TODO deal with refresh breaking native loading (e.g SWT) frameworkWiring.refreshBundles(null); }