Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2011-02-16 04:34:15 -0500
committerGlyn Normington2011-02-16 04:34:15 -0500
commitb8a931c0ab33ac20b2b757acda2ac17d699d32eb (patch)
treef9ae0ca79d28a81822b6db26c7407b0329d09aac /org.eclipse.virgo.kernel.model
parentaaa850bd112c8c315c4fe8f9b461a6df4cb27817 (diff)
downloadorg.eclipse.virgo.kernel-b8a931c0ab33ac20b2b757acda2ac17d699d32eb.tar.gz
org.eclipse.virgo.kernel-b8a931c0ab33ac20b2b757acda2ac17d699d32eb.tar.xz
org.eclipse.virgo.kernel-b8a931c0ab33ac20b2b757acda2ac17d699d32eb.zip
bug 337214: use user region bundle context consistently
Diffstat (limited to 'org.eclipse.virgo.kernel.model')
-rw-r--r--org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializer.java13
-rw-r--r--org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializerTests.java9
2 files changed, 9 insertions, 13 deletions
diff --git a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializer.java b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializer.java
index 813d0fe0..d9869fbf 100644
--- a/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializer.java
+++ b/org.eclipse.virgo.kernel.model/src/main/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializer.java
@@ -48,27 +48,24 @@ public final class ModelBundleListenerInitializer {
private final BundleListener bundleListener;
- private final BundleContext systemBundleContext;
-
public ModelBundleListenerInitializer(@NonNull RuntimeArtifactRepository artifactRepository, @NonNull PackageAdminUtil packageAdminUtil,
@NonNull BundleContext kernelBundleContext, @NonNull BundleContext userRegionBundleContext) {
this.artifactRepository = artifactRepository;
this.packageAdminUtil = packageAdminUtil;
this.kernelBundleContext = kernelBundleContext;
this.userRegionBundleContext = userRegionBundleContext;
- this.systemBundleContext = kernelBundleContext.getBundle(0L).getBundleContext();
this.bundleListener = new ModelBundleListener(kernelBundleContext, artifactRepository, packageAdminUtil);
}
/**
* Registers a {@link BundleListener} with the OSGi framework. Enumerates any existing {@link Bundle}s that exist
- * from the OSGi framework.
+ * in the user region.
*/
@PostConstruct
public void initialize() {
- // Register the listener with the system bundle to see all bundles.
- this.systemBundleContext.addBundleListener(this.bundleListener);
- // Find bundles using the user region context as application bundles are added to the user region.
+ // Register the listener with the user region bundle context to see all bundles in the user region.
+ this.userRegionBundleContext.addBundleListener(this.bundleListener);
+ // Find bundles in the user region as the listener has almost certainly missed their installation.
for (Bundle bundle : this.userRegionBundleContext.getBundles()) {
try {
this.artifactRepository.add(new BundleArtifact(this.kernelBundleContext, this.packageAdminUtil, bundle));
@@ -84,6 +81,6 @@ public final class ModelBundleListenerInitializer {
*/
@PreDestroy
public void destroy() {
- this.systemBundleContext.removeBundleListener(this.bundleListener);
+ this.userRegionBundleContext.removeBundleListener(this.bundleListener);
}
}
diff --git a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializerTests.java b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializerTests.java
index 3d6811dc..9abb68d5 100644
--- a/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializerTests.java
+++ b/org.eclipse.virgo.kernel.model/src/test/java/org/eclipse/virgo/kernel/model/internal/bundle/ModelBundleListenerInitializerTests.java
@@ -48,7 +48,6 @@ public class ModelBundleListenerInitializerTests {
this.systemBundleContext.addInstalledBundle(bundle);
String filterString = String.format("(&(objectClass=%s)(artifactType=bundle))", DependencyDeterminer.class.getCanonicalName());
this.bundleContext.addFilter(filterString, new TrueFilter(filterString));
- //this.bundleContext.addInstalledBundle(bundle);
}
private final ModelBundleListenerInitializer initializer = new ModelBundleListenerInitializer(artifactRepository, packageAdminUtil, bundleContext, bundleContext);
@@ -75,17 +74,17 @@ public class ModelBundleListenerInitializerTests {
@Test
public void initialize() throws IOException, InvalidSyntaxException {
- assertEquals(0, this.systemBundleContext.getBundleListeners().size());
+ assertEquals(0, this.bundleContext.getBundleListeners().size());
this.initializer.initialize();
- assertEquals(1, this.systemBundleContext.getBundleListeners().size());
+ assertEquals(1, this.bundleContext.getBundleListeners().size());
assertEquals(1, this.artifactRepository.getArtifacts().size());
}
@Test
public void destroy() throws IOException, InvalidSyntaxException {
this.initializer.initialize();
- assertEquals(1, this.systemBundleContext.getBundleListeners().size());
+ assertEquals(1, this.bundleContext.getBundleListeners().size());
this.initializer.destroy();
- assertEquals(0, this.systemBundleContext.getBundleListeners().size());
+ assertEquals(0, this.bundleContext.getBundleListeners().size());
}
}

Back to the top