1 package org
.argeo
.init
.osgi
;
3 import java
.lang
.System
.Logger
;
4 import java
.lang
.System
.Logger
.Level
;
5 import java
.util
.Objects
;
7 import org
.argeo
.init
.Service
;
8 import org
.argeo
.init
.logging
.ThinLoggerFinder
;
9 import org
.osgi
.framework
.BundleActivator
;
10 import org
.osgi
.framework
.BundleContext
;
13 * An OSGi configurator. See
14 * <a href="http://wiki.eclipse.org/Configurator">http:
15 * //wiki.eclipse.org/Configurator</a>
17 public class Activator
implements BundleActivator
{
19 // must be called first
20 ThinLoggerFinder
.lazyInit();
22 private final static Logger logger
= System
.getLogger(Activator
.class.getName());
24 private Long checkpoint
= null;
26 private boolean argeoInit
= false;
27 /** Not null if we created it ourselves. */
28 private OsgiRuntimeContext runtimeContext
;
30 public void start(final BundleContext bundleContext
) throws Exception
{
31 // The OSGi runtime was created by us, and therefore already initialized
32 argeoInit
= Boolean
.parseBoolean(bundleContext
.getProperty(Service
.PROP_ARGEO_INIT_MAIN
));
34 if (runtimeContext
== null) {
35 runtimeContext
= new OsgiRuntimeContext(bundleContext
);
36 logger
.log(Level
.DEBUG
, () -> "Argeo init via OSGi activator");
40 // Thread adminThread = new AdminThread(bundleContext);
41 // adminThread.start();
44 // OsgiBoot osgiBoot = new OsgiBoot(bundleContext);
45 if (checkpoint
== null) {
46 // osgiBoot.bootstrap();
47 checkpoint
= System
.currentTimeMillis();
49 runtimeContext
.update();
50 checkpoint
= System
.currentTimeMillis();
55 public void stop(BundleContext context
) throws Exception
{
57 Objects
.nonNull(runtimeContext
);
58 runtimeContext
.stop(context
);
59 runtimeContext
= null;