Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2013-07-31 15:10:15 +0000
committerThomas Watson2013-08-09 20:18:55 +0000
commit1630d76cda1dba192565363cbcd8f05372184ed9 (patch)
treeedeb706e8d9c00cbfbd09223e097ab8357b47a80
parent59a3c895df828b25e603da6d9e2fd829ba43f022 (diff)
downloadrt.equinox.framework-1630d76cda1dba192565363cbcd8f05372184ed9.tar.gz
rt.equinox.framework-1630d76cda1dba192565363cbcd8f05372184ed9.tar.xz
rt.equinox.framework-1630d76cda1dba192565363cbcd8f05372184ed9.zip
Bug 414153 - During framework init resolutions should be scoped to the system bundle
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java2
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java42
2 files changed, 32 insertions, 12 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
index 56e245068..200f6eb89 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
@@ -35,7 +35,7 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor {
public EquinoxContainerAdaptor(EquinoxContainer container, Storage storage, Map<Long, Generation> initial) {
this.container = container;
this.storage = storage;
- this.hooks = new OSGiFrameworkHooks(container);
+ this.hooks = new OSGiFrameworkHooks(container, storage);
this.initial = initial;
this.moduleClassLoaderParent = getModuleClassLoaderParent(container.getConfiguration());
this.lastSecurityAdminFlush = new AtomicLong();
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java
index f4d4f8d06..4e1f47807 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java
@@ -13,13 +13,13 @@ package org.eclipse.osgi.internal.framework;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
-import org.eclipse.osgi.container.Module;
-import org.eclipse.osgi.container.ModuleCollisionHook;
+import org.eclipse.osgi.container.*;
import org.eclipse.osgi.framework.internal.core.Msg;
import org.eclipse.osgi.framework.util.ArrayMap;
import org.eclipse.osgi.internal.debug.Debug;
import org.eclipse.osgi.internal.serviceregistry.*;
import org.eclipse.osgi.report.resolution.ResolutionReport;
+import org.eclipse.osgi.storage.Storage;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.*;
import org.osgi.framework.hooks.bundle.CollisionHook;
@@ -32,8 +32,8 @@ class OSGiFrameworkHooks {
private final ResolverHookFactory resolverHookFactory;
private final ModuleCollisionHook collisionHook;
- OSGiFrameworkHooks(EquinoxContainer container) {
- resolverHookFactory = new CoreResolverHookFactory(container);
+ OSGiFrameworkHooks(EquinoxContainer container, Storage storage) {
+ resolverHookFactory = new CoreResolverHookFactory(container, storage);
collisionHook = new BundleCollisionHook(container);
}
@@ -148,10 +148,12 @@ class OSGiFrameworkHooks {
final Debug debug;
final EquinoxContainer container;
+ final Storage storage;
- public CoreResolverHookFactory(EquinoxContainer container) {
+ public CoreResolverHookFactory(EquinoxContainer container, Storage storage) {
this.container = container;
this.debug = container.getConfiguration().getDebug();
+ this.storage = storage;
}
void handleHookException(Throwable t, Object hook, String method) {
@@ -179,11 +181,13 @@ class OSGiFrameworkHooks {
if (debug.DEBUG_HOOKS) {
Debug.println("ResolverHook.begin"); //$NON-NLS-1$
}
+ ModuleContainer mContainer = storage.getModuleContainer();
+ Module systemModule = mContainer == null ? null : mContainer.getModule(0);
ServiceRegistry registry = container.getServiceRegistry();
- if (registry == null) {
- return new CoreResolverHook(Collections.<HookReference> emptyList());
+ if (registry == null || systemModule == null) {
+ return new CoreResolverHook(Collections.<HookReference> emptyList(), systemModule);
}
- Module systemModule = container.getStorage().getModuleContainer().getModule(0);
+
BundleContextImpl context = (BundleContextImpl) EquinoxContainer.secureAction.getContext(systemModule.getBundle());
ServiceReferenceImpl<ResolverHookFactory>[] refs = getHookReferences(registry, context);
@@ -200,7 +204,7 @@ class OSGiFrameworkHooks {
} catch (Throwable t) {
// need to force an end call on the ResolverHooks we got and release them
try {
- new CoreResolverHook(hookRefs).end();
+ new CoreResolverHook(hookRefs, systemModule).end();
} catch (Throwable endError) {
// we are already in failure mode; just continue
}
@@ -209,22 +213,38 @@ class OSGiFrameworkHooks {
}
}
}
- return new CoreResolverHook(hookRefs);
+ return new CoreResolverHook(hookRefs, systemModule);
}
class CoreResolverHook implements ResolutionReport.Listener, ResolverHook {
private final List<HookReference> hooks;
+ private final Module systemModule;
private volatile ResolutionReport report;
- CoreResolverHook(List<HookReference> hooks) {
+ CoreResolverHook(List<HookReference> hooks, Module systemModule) {
this.hooks = hooks;
+ this.systemModule = systemModule;
}
public void filterResolvable(Collection<BundleRevision> candidates) {
if (debug.DEBUG_HOOKS) {
Debug.println("ResolverHook.filterResolvable(" + candidates + ")"); //$NON-NLS-1$ //$NON-NLS-2$
}
+ if (systemModule == null || !Module.RESOLVED_SET.contains(systemModule.getState())) {
+ // only allow the system bundle and its fragments resolve during boot up
+ for (Iterator<BundleRevision> iCandidates = candidates.iterator(); iCandidates.hasNext();) {
+ BundleRevision revision = iCandidates.next();
+ if ((revision.getTypes() & BundleRevision.TYPE_FRAGMENT) == 0) {
+ // host bundle; check if it is the system bundle
+ if (revision.getBundle().getBundleId() != 0) {
+ iCandidates.remove();
+ }
+ }
+ // just leave all fragments. Only the ones that are system bundle fragments will resolve
+ // since we removed all the other possible hosts.
+ }
+ }
if (hooks.isEmpty())
return;
candidates = new ShrinkableCollection<BundleRevision>(candidates);

Back to the top