X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2Fa2%2FOsgiContext.java;h=7f1133f676a034a8b1fde29a4a683877dbe46b1b;hb=71d0bea8d7aa3592f7f2b7c89bb8dd91b6d8bb6d;hp=0064ab9eddbb1c4d3c8c37148eb9efaaa68f61aa;hpb=a893bef98a50cbe52949dbea9e51881f436a4af4;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.init/src/org/argeo/init/a2/OsgiContext.java b/org.argeo.init/src/org/argeo/init/a2/OsgiContext.java index 0064ab9ed..7f1133f67 100644 --- a/org.argeo.init/src/org/argeo/init/a2/OsgiContext.java +++ b/org.argeo.init/src/org/argeo/init/a2/OsgiContext.java @@ -6,13 +6,18 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; import org.osgi.framework.Version; -/** A running OSGi bundle context seen as a {@link AbstractProvisioningSource}. */ +/** + * A running OSGi bundle context seen as a {@link AbstractProvisioningSource}. + */ class OsgiContext extends AbstractProvisioningSource { private final BundleContext bc; + private A2Contribution runtimeContribution; + public OsgiContext(BundleContext bc) { super(false); this.bc = bc; + runtimeContribution = getOrAddContribution(A2Contribution.RUNTIME); } public OsgiContext() { @@ -25,16 +30,19 @@ class OsgiContext extends AbstractProvisioningSource { } void load() { - A2Contribution runtimeContribution = getOrAddContribution( A2Contribution.RUNTIME); for (Bundle bundle : bc.getBundles()) { - // OsgiBootUtils.debug(bundle.getDataFile("/")); - String componentId = bundle.getSymbolicName(); - Version version = bundle.getVersion(); - A2Component component = runtimeContribution.getOrAddComponent(componentId); - A2Module module = component.getOrAddModule(version, bundle); - if (OsgiBootUtils.isDebug()) - OsgiBootUtils.debug("Registered " + module + " (location id: " + bundle.getLocation() + ")"); + registerBundle(bundle); } } + + void registerBundle(Bundle bundle) { + String componentId = bundle.getSymbolicName(); + Version version = bundle.getVersion(); + A2Component component = runtimeContribution.getOrAddComponent(componentId); + A2Module module = component.getOrAddModule(version, bundle); + if (OsgiBootUtils.isDebug()) + OsgiBootUtils.debug("Registered bundle module " + module + " (location id: " + bundle.getLocation() + ")"); + + } }