diff options
author | Thomas Watson | 2013-05-22 13:18:58 +0000 |
---|---|---|
committer | Thomas Watson | 2013-05-22 13:18:58 +0000 |
commit | 6d2a871763910eedb21e4cef967c4cabeceef1c9 (patch) | |
tree | 39274c6677d7df0b9e819f4f31a78f2813db0c54 /bundles/org.eclipse.osgi | |
parent | 3c19054e26939de6dc8d70d87904d667536a70e6 (diff) | |
download | rt.equinox.framework-6d2a871763910eedb21e4cef967c4cabeceef1c9.tar.gz rt.equinox.framework-6d2a871763910eedb21e4cef967c4cabeceef1c9.tar.xz rt.equinox.framework-6d2a871763910eedb21e4cef967c4cabeceef1c9.zip |
Bug 408629 - [unity] Preserve firing lazy start trigger when bundle is marked for eager start.
- Fix to fire lazy trigger for eager start bundles
Diffstat (limited to 'bundles/org.eclipse.osgi')
3 files changed, 40 insertions, 23 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/Module.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/Module.java index ead012a01..563aafa18 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/Module.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/Module.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 IBM Corporation and others. + * Copyright (c) 2012, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,15 +10,14 @@ *******************************************************************************/ package org.eclipse.osgi.container; -import java.util.*; +import java.util.Arrays; +import java.util.EnumSet; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; import org.eclipse.osgi.container.ModuleContainerAdaptor.ModuleEvent; -import org.eclipse.osgi.container.namespaces.EquinoxModuleDataNamespace; import org.osgi.framework.*; import org.osgi.framework.startlevel.BundleStartLevel; import org.osgi.framework.wiring.BundleRevision; -import org.osgi.resource.Capability; import org.osgi.service.resolver.ResolutionException; /** @@ -138,9 +137,9 @@ public abstract class Module implements BundleReference, BundleStartLevel, Compa */ AUTO_START, /** - * The module has been set to use its activation policy + * The module has been set to use its activation policy. */ - USE_ACTIVATION_POLICY, + USE_ACTIVATION_POLICY } /** @@ -643,14 +642,8 @@ public abstract class Module implements BundleReference, BundleStartLevel, Compa return hasLazyActivatePolicy(); } - private boolean hasLazyActivatePolicy() { + boolean hasLazyActivatePolicy() { ModuleRevision current = getCurrentRevision(); - if (current == null) - return false; - List<Capability> capabilities = current.getCapabilities(EquinoxModuleDataNamespace.MODULE_DATA_NAMESPACE); - if (capabilities.isEmpty()) - return false; - Capability moduleData = capabilities.get(0); - return EquinoxModuleDataNamespace.CAPABILITY_ACTIVATION_POLICY_LAZY.equals(moduleData.getAttributes().get(EquinoxModuleDataNamespace.CAPABILITY_ACTIVATION_POLICY)); + return current == null ? false : current.hasLazyActivatePolicy(); } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java index 6426dec1b..91df56fd9 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 IBM Corporation and others. + * Copyright (c) 2012, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,6 +13,7 @@ package org.eclipse.osgi.container; import java.util.*; import java.util.Map.Entry; import org.eclipse.osgi.container.ModuleRevisionBuilder.GenericInfo; +import org.eclipse.osgi.container.namespaces.EquinoxModuleDataNamespace; import org.eclipse.osgi.internal.container.Converters; import org.osgi.framework.Bundle; import org.osgi.framework.Version; @@ -33,6 +34,7 @@ public final class ModuleRevision implements BundleRevision { private final List<ModuleRequirement> requirements; private final ModuleRevisions revisions; private final Object revisionInfo; + private volatile Boolean lazyActivationPolicy = null; ModuleRevision(String symbolicName, Version version, int types, List<GenericInfo> capabilityInfos, List<GenericInfo> requirementInfos, ModuleRevisions revisions, Object revisionInfo) { this.symbolicName = symbolicName; @@ -162,6 +164,26 @@ public final class ModuleRevision implements BundleRevision { return revisionInfo; } + /** + * A convenience method to quickly determine if this revision + * has declared the lazy activation policy. + * @return true if the lazy activation policy has been declared by this module; otherwise false is returned. + */ + public boolean hasLazyActivatePolicy() { + Boolean currentPolicy = lazyActivationPolicy; + if (currentPolicy != null) { + return currentPolicy.booleanValue(); + } + boolean lazyPolicy = false; + List<Capability> data = getCapabilities(EquinoxModuleDataNamespace.MODULE_DATA_NAMESPACE); + if (!data.isEmpty()) { + Capability moduleData = data.get(0); + lazyPolicy = EquinoxModuleDataNamespace.CAPABILITY_ACTIVATION_POLICY_LAZY.equals(moduleData.getAttributes().get(EquinoxModuleDataNamespace.CAPABILITY_ACTIVATION_POLICY)); + } + lazyActivationPolicy = Boolean.valueOf(lazyPolicy); + return lazyPolicy; + } + boolean isCurrent() { return !revisions.isUninstalled() && this.equals(revisions.getCurrentRevision()); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/EclipseLazyStarter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/EclipseLazyStarter.java index 0f37b447c..b118179d4 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/EclipseLazyStarter.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/hooks/EclipseLazyStarter.java @@ -11,14 +11,13 @@ package org.eclipse.osgi.internal.hooks; -import org.eclipse.osgi.framework.internal.core.Msg; - import java.security.AccessController; import java.util.*; import org.eclipse.osgi.container.*; import org.eclipse.osgi.container.Module.StartOptions; import org.eclipse.osgi.container.Module.State; import org.eclipse.osgi.container.namespaces.EquinoxModuleDataNamespace; +import org.eclipse.osgi.framework.internal.core.Msg; import org.eclipse.osgi.framework.log.FrameworkLogEntry; import org.eclipse.osgi.framework.util.SecureAction; import org.eclipse.osgi.internal.framework.EquinoxContainer; @@ -140,7 +139,12 @@ public class EclipseLazyStarter extends ClassLoaderHook { if (error != null) throw error; } - return module.isPersistentlyStarted() && module.isActivationPolicyUsed() && isLazyStartable(className, revision); + // The module is persistently started and has the lazy activation policy but has not entered the LAZY_STARTING state + // There are 2 cases where this can happen + // 1) The start-level thread has not gotten to transitioning the bundle to LAZY_STARTING yet + // 2) The bundle is marked for eager activation and the start-level thread has not activated it yet + // In both cases we need to fire the lazy start trigger to activate the bundle if the start-level is met + return module.isPersistentlyStarted() && isLazyStartable(className, revision); } return false; } @@ -149,17 +153,15 @@ public class EclipseLazyStarter extends ClassLoaderHook { } private boolean isLazyStartable(String className, ModuleRevision revision) { + if (!revision.hasLazyActivatePolicy()) { + return false; + } List<ModuleCapability> moduleDatas = revision.getModuleCapabilities(EquinoxModuleDataNamespace.MODULE_DATA_NAMESPACE); if (moduleDatas.isEmpty()) { return false; } Map<String, Object> moduleDataAttrs = moduleDatas.get(0).getAttributes(); - String policy = (String) moduleDataAttrs.get(EquinoxModuleDataNamespace.CAPABILITY_ACTIVATION_POLICY); - if (!EquinoxModuleDataNamespace.CAPABILITY_ACTIVATION_POLICY_LAZY.equals(policy)) { - return false; - } - @SuppressWarnings("unchecked") List<String> excludes = (List<String>) moduleDataAttrs.get(EquinoxModuleDataNamespace.CAPABILITY_LAZY_EXCLUDE_ATTRIBUTE); @SuppressWarnings("unchecked") |