1 package org
.argeo
.osgi
.boot
.a2
;
3 import org
.argeo
.osgi
.boot
.OsgiBootUtils
;
4 import org
.osgi
.framework
.Bundle
;
5 import org
.osgi
.framework
.BundleContext
;
6 import org
.osgi
.framework
.FrameworkUtil
;
7 import org
.osgi
.framework
.Version
;
9 class OsgiContext
extends ProvisioningSource
{
10 private final BundleContext bc
;
12 public OsgiContext(BundleContext bc
) {
17 public OsgiContext() {
18 Bundle bundle
= FrameworkUtil
.getBundle(OsgiContext
.class);
20 throw new IllegalArgumentException(
21 "OSGi Boot bundle must be started or a bundle context must be specified");
22 this.bc
= bundle
.getBundleContext();
26 A2Contribution runtimeContribution
= new A2Contribution(this, A2Contribution
.RUNTIME
);
27 for (Bundle bundle
: bc
.getBundles()) {
28 // OsgiBootUtils.debug(bundle.getDataFile("/"));
29 String componentId
= bundle
.getSymbolicName();
30 Version version
= bundle
.getVersion();
31 A2Component component
= runtimeContribution
.getOrAddComponent(componentId
);
32 A2Module module
= component
.getOrAddModule(version
, bundle
);
33 if (OsgiBootUtils
.isDebug())
34 OsgiBootUtils
.debug("Registered " + module
+ " (location id: " + bundle
.getLocation() + ")");