1 package org
.argeo
.init
.a2
;
3 import org
.argeo
.init
.osgi
.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 /** A running OSGi bundle context seen as a {@link AbstractProvisioningSource}. */
10 class OsgiContext
extends AbstractProvisioningSource
{
11 private final BundleContext bc
;
13 public OsgiContext(BundleContext bc
) {
18 public OsgiContext() {
20 Bundle bundle
= FrameworkUtil
.getBundle(OsgiContext
.class);
22 throw new IllegalArgumentException(
23 "OSGi Boot bundle must be started or a bundle context must be specified");
24 this.bc
= bundle
.getBundleContext();
28 A2Contribution runtimeContribution
= getOrAddContribution( A2Contribution
.RUNTIME
);
29 for (Bundle bundle
: bc
.getBundles()) {
30 // OsgiBootUtils.debug(bundle.getDataFile("/"));
31 String componentId
= bundle
.getSymbolicName();
32 Version version
= bundle
.getVersion();
33 A2Component component
= runtimeContribution
.getOrAddComponent(componentId
);
34 A2Module module
= component
.getOrAddModule(version
, bundle
);
35 if (OsgiBootUtils
.isDebug())
36 OsgiBootUtils
.debug("Registered " + module
+ " (location id: " + bundle
.getLocation() + ")");