]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.init/src/org/argeo/init/osgi/Activator.java
Improve OSGi initialisation
[lgpl/argeo-commons.git] / org.argeo.init / src / org / argeo / init / osgi / Activator.java
index 5a9527041bf01e5c99bb8cc9598d40c620a6b1ee..518751f91e655f27bcadda1e4ea02e21d0e056fa 100644 (file)
@@ -1,9 +1,10 @@
 package org.argeo.init.osgi;
 
-import java.util.Enumeration;
-import java.util.ResourceBundle;
-import java.util.Vector;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
+import java.util.Objects;
 
+import org.argeo.init.logging.ThinLoggerFinder;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 
@@ -13,44 +14,40 @@ import org.osgi.framework.BundleContext;
  * //wiki.eclipse.org/Configurator</a>
  */
 public class Activator implements BundleActivator {
+       static {
+               // must be called first
+               ThinLoggerFinder.lazyInit();
+       }
+       private Logger logger = System.getLogger(Activator.class.getName());
+
        private Long checkpoint = null;
 
+       /** Not null if we created it ourselves. */
+       private OsgiRuntimeContext runtimeContext;
+
        public void start(final BundleContext bundleContext) throws Exception {
+               if (runtimeContext == null) {
+                       runtimeContext = new OsgiRuntimeContext(bundleContext);
+               }
+               logger.log(Level.DEBUG, () -> "Argeo init via OSGi activator");
+
                // admin thread
-               Thread adminThread = new AdminThread(bundleContext);
-               adminThread.start();
+//             Thread adminThread = new AdminThread(bundleContext);
+//             adminThread.start();
 
                // bootstrap
-               OsgiBoot osgiBoot = new OsgiBoot(bundleContext);
+//             OsgiBoot osgiBoot = new OsgiBoot(bundleContext);
                if (checkpoint == null) {
-                       osgiBoot.bootstrap();
+//                     osgiBoot.bootstrap();
                        checkpoint = System.currentTimeMillis();
                } else {
-                       osgiBoot.update();
+                       runtimeContext.update();
                        checkpoint = System.currentTimeMillis();
                }
        }
 
        public void stop(BundleContext context) throws Exception {
-       }
-
-       class JournaldResourceBundle extends ResourceBundle {
-
-               @Override
-               protected Object handleGetObject(String key) {
-                       switch (key) {
-                       case "ERROR":
-                               return "<5>";
-                       }
-                       return null;
-               }
-
-               @Override
-               public Enumeration<String> getKeys() {
-                       Vector<String> keys = new Vector<>();
-                       keys.add("ERROR");
-                       return keys.elements();
-               }
-
+               Objects.nonNull(runtimeContext);
+               runtimeContext.stop(context);
        }
 }