X-Git-Url: http://git.argeo.org/?p=lgpl%2Fargeo-commons.git;a=blobdiff_plain;f=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2Fa2%2FOsgiContext.java;fp=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2Fa2%2FOsgiContext.java;h=0000000000000000000000000000000000000000;hp=7f1133f676a034a8b1fde29a4a683877dbe46b1b;hb=b95462873703848193e56fcbe997693630db6121;hpb=55d88fba80cec198a0f11ba7545e19878c51fc5e diff --git a/org.argeo.init/src/org/argeo/init/a2/OsgiContext.java b/org.argeo.init/src/org/argeo/init/a2/OsgiContext.java deleted file mode 100644 index 7f1133f67..000000000 --- a/org.argeo.init/src/org/argeo/init/a2/OsgiContext.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.argeo.init.a2; - -import org.argeo.init.osgi.OsgiBootUtils; -import org.osgi.framework.Bundle; -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}. - */ -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() { - super(false); - Bundle bundle = FrameworkUtil.getBundle(OsgiContext.class); - if (bundle == null) - throw new IllegalArgumentException( - "OSGi Boot bundle must be started or a bundle context must be specified"); - this.bc = bundle.getBundleContext(); - } - - void load() { - for (Bundle bundle : bc.getBundles()) { - 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() + ")"); - - } -}