]> git.argeo.org Git - lgpl/argeo-commons.git/blob - osgi/Activator.java
Prepare next development cycle
[lgpl/argeo-commons.git] / osgi / Activator.java
1 package org.argeo.init.osgi;
2
3 import java.lang.System.Logger;
4 import java.lang.System.Logger.Level;
5 import java.util.Objects;
6
7 import org.argeo.init.logging.ThinLoggerFinder;
8 import org.osgi.framework.BundleActivator;
9 import org.osgi.framework.BundleContext;
10
11 /**
12 * An OSGi configurator. See
13 * <a href="http://wiki.eclipse.org/Configurator">http:
14 * //wiki.eclipse.org/Configurator</a>
15 */
16 public class Activator implements BundleActivator {
17 static {
18 // must be called first
19 ThinLoggerFinder.lazyInit();
20 }
21 private Logger logger = System.getLogger(Activator.class.getName());
22
23 private Long checkpoint = null;
24
25 /** Not null if we created it ourselves. */
26 private OsgiRuntimeContext runtimeContext;
27
28 public void start(final BundleContext bundleContext) throws Exception {
29 if (runtimeContext == null) {
30 runtimeContext = new OsgiRuntimeContext(bundleContext);
31 }
32 logger.log(Level.DEBUG, () -> "Argeo init via OSGi activator");
33
34 // admin thread
35 // Thread adminThread = new AdminThread(bundleContext);
36 // adminThread.start();
37
38 // bootstrap
39 // OsgiBoot osgiBoot = new OsgiBoot(bundleContext);
40 if (checkpoint == null) {
41 // osgiBoot.bootstrap();
42 checkpoint = System.currentTimeMillis();
43 } else {
44 runtimeContext.update();
45 checkpoint = System.currentTimeMillis();
46 }
47 }
48
49 public void stop(BundleContext context) throws Exception {
50 Objects.nonNull(runtimeContext);
51 runtimeContext.stop(context);
52 }
53 }