Clean up Argeo Init
[lgpl/argeo-commons.git] / org.argeo.init / src / org / argeo / init / osgi / OsgiBootDiagnostics.java
index 72d9a3e64f683b991530e5132c2bce07fcc78529..074ecedb6b6dfd3c0b85451f84e4eee36953325b 100644 (file)
@@ -1,5 +1,8 @@
 package org.argeo.init.osgi;
 
+import static java.lang.System.Logger.Level.WARNING;
+
+import java.lang.System.Logger;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -14,13 +17,15 @@ import org.osgi.framework.ServiceReference;
 import org.osgi.service.packageadmin.ExportedPackage;
 import org.osgi.service.packageadmin.PackageAdmin;
 
-@SuppressWarnings("deprecation")
 class OsgiBootDiagnostics {
+       private final static Logger logger = System.getLogger(OsgiBootDiagnostics.class.getName());
+
        private final BundleContext bundleContext;
 
        public OsgiBootDiagnostics(BundleContext bundleContext) {
                this.bundleContext = bundleContext;
        }
+
        /*
         * DIAGNOSTICS
         */
@@ -40,7 +45,18 @@ class OsgiBootDiagnostics {
                }
 
                if (unresolvedBundles.size() != 0) {
-                       OsgiBootUtils.warn("Unresolved bundles " + unresolvedBundles);
+                       logger.log(WARNING, "Unresolved bundles " + unresolvedBundles);
+               }
+
+               // try to start unresolved bundles in order to trigger diagnostics
+               // (this should not have side-effects since unresolved bundles won't be able to
+               // start)
+               for (Bundle b : unresolvedBundles) {
+                       try {
+                               b.start();
+                       } catch (Exception e) {
+                               e.printStackTrace();
+                       }
                }
        }