diff options
author | Simon Kaegi | 2009-03-06 20:07:00 +0000 |
---|---|---|
committer | Simon Kaegi | 2009-03-06 20:07:00 +0000 |
commit | f2bb1f0d9f5d1772cd8c4188007a2e3f1ed6c4c2 (patch) | |
tree | 7b37ba5d8f92226a8176adb457930d008c90d819 /bundles | |
parent | 277fd5efc3648a2556f6ee72e3696404e339ff3f (diff) | |
download | rt.equinox.p2-f2bb1f0d9f5d1772cd8c4188007a2e3f1ed6c4c2.tar.gz rt.equinox.p2-f2bb1f0d9f5d1772cd8c4188007a2e3f1ed6c4c2.tar.xz rt.equinox.p2-f2bb1f0d9f5d1772cd8c4188007a2e3f1ed6c4c2.zip |
Bug 262243 [eclipse] markStarted action should ignore OSGi fragment bundles
Diffstat (limited to 'bundles')
7 files changed, 147 insertions, 19 deletions
diff --git a/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/provisional/frameworkadmin/BundleInfo.java b/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/provisional/frameworkadmin/BundleInfo.java index a1ae67b75..5c5e26f22 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/provisional/frameworkadmin/BundleInfo.java +++ b/bundles/org.eclipse.equinox.frameworkadmin/src/org/eclipse/equinox/internal/provisional/frameworkadmin/BundleInfo.java @@ -24,6 +24,7 @@ public class BundleInfo { private String symbolicName = null; private String version = null; + private boolean fragment = false; private URI baseLocation; private URI location; private long bundleId = NO_BUNDLEID; @@ -108,6 +109,10 @@ public class BundleInfo { return resolved; } + public boolean isFragment() { + return fragment; + } + public void setBundleId(long bundleId) { this.bundleId = bundleId; } @@ -144,6 +149,10 @@ public class BundleInfo { this.version = value; } + public void setFragment(boolean fragment) { + this.fragment = fragment; + } + /* (non-Javadoc) * @see java.lang.Object#toString() */ @@ -156,6 +165,9 @@ public class BundleInfo { if (version != null) buffer.append(version); + buffer.append(", fragment="); //$NON-NLA-1$ + buffer.append(fragment); + if (baseLocation != null) { buffer.append(", baseLocation="); //$NON-NLS-1$ buffer.append(baseLocation); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/MarkStartedActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/MarkStartedActionTest.java index 6af070643..dbc34b598 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/MarkStartedActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/MarkStartedActionTest.java @@ -132,6 +132,52 @@ public class MarkStartedActionTest extends AbstractProvisioningTest { assertTrue(isMarkedStarted(manipulator, osgiTarget, false)); } + public void testExecuteOnFragmentBundleResultsInBundleNotBeingMarkedStarted() { + Properties profileProperties = new Properties(); + File installFolder = getTempFolder(); + profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); + profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); + IProfile profile = createProfile("test", null, profileProperties); + + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi.fragment_1.0.0.jar"); + File targetPlugins = new File(installFolder, "plugins"); + assertTrue(targetPlugins.mkdir()); + File osgiTarget = new File(targetPlugins, "org.eclipse.osgi.fragment_1.0.0.jar"); + copy("2.0", osgiSource, osgiTarget); + + BundleDescription bundleDescription = BundlesAction.createBundleDescription(osgiTarget); + IArtifactKey key = BundlesAction.createBundleArtifactKey(bundleDescription.getSymbolicName(), bundleDescription.getVersion().toString()); + IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, osgiTarget); + IInstallableUnit iu = createBundleIU(bundleDescription, osgiTarget.isDirectory(), key); + bundlePool.addDescriptor(descriptor); + + Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_PROFILE, profile); + parameters.put(InstallableUnitPhase.PARM_ARTIFACT_REQUESTS, new ArrayList()); + EclipseTouchpoint touchpoint = new EclipseTouchpoint(); + touchpoint.initializePhase(null, profile, "test", parameters); + InstallableUnitOperand operand = new InstallableUnitOperand(null, iu); + parameters.put("iu", operand.second()); + touchpoint.initializeOperand(profile, operand, parameters); + + parameters.put(ActionConstants.PARM_STARTED, Boolean.TRUE.toString()); + parameters = Collections.unmodifiableMap(parameters); + + Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR); + assertNotNull(manipulator); + + BundleInfo bundleInfo = Util.createBundleInfo(osgiTarget, Util.getManifest(iu.getTouchpointData())); + manipulator.getConfigData().addBundle(bundleInfo); + assertTrue(isMarkedStarted(manipulator, osgiTarget, false)); + + MarkStartedAction action = new MarkStartedAction(); + action.execute(parameters); + assertTrue(isMarkedStarted(manipulator, osgiTarget, false)); + action.undo(parameters); + assertTrue(isMarkedStarted(manipulator, osgiTarget, false)); + } + private boolean isMarkedStarted(Manipulator manipulator, File osgiTarget, boolean started) { URI location = osgiTarget.toURI(); BundleInfo[] bundles = manipulator.getConfigData().getBundles(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetStartLevelActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetStartLevelActionTest.java index 8463dc7c9..c947efc68 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetStartLevelActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetStartLevelActionTest.java @@ -132,6 +132,52 @@ public class SetStartLevelActionTest extends AbstractProvisioningTest { assertTrue(isStartLevel(manipulator, osgiTarget, -1)); } + public void testExecuteOnFragmentBundleResultsInBundleNotBeingMarkedStarted() { + Properties profileProperties = new Properties(); + File installFolder = getTempFolder(); + profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); + profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); + IProfile profile = createProfile("test", null, profileProperties); + + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi.fragment_1.0.0.jar"); + File targetPlugins = new File(installFolder, "plugins"); + assertTrue(targetPlugins.mkdir()); + File osgiTarget = new File(targetPlugins, "org.eclipse.osgi.fragment_1.0.0.jar"); + copy("2.0", osgiSource, osgiTarget); + + BundleDescription bundleDescription = BundlesAction.createBundleDescription(osgiTarget); + IArtifactKey key = BundlesAction.createBundleArtifactKey(bundleDescription.getSymbolicName(), bundleDescription.getVersion().toString()); + IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, osgiTarget); + IInstallableUnit iu = createBundleIU(bundleDescription, osgiTarget.isDirectory(), key); + bundlePool.addDescriptor(descriptor); + + Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_PROFILE, profile); + parameters.put(InstallableUnitPhase.PARM_ARTIFACT_REQUESTS, new ArrayList()); + EclipseTouchpoint touchpoint = new EclipseTouchpoint(); + touchpoint.initializePhase(null, profile, "test", parameters); + InstallableUnitOperand operand = new InstallableUnitOperand(null, iu); + parameters.put("iu", operand.second()); + touchpoint.initializeOperand(profile, operand, parameters); + + parameters.put(ActionConstants.PARM_START_LEVEL, "0"); + parameters = Collections.unmodifiableMap(parameters); + + Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR); + assertNotNull(manipulator); + + BundleInfo bundleInfo = Util.createBundleInfo(osgiTarget, Util.getManifest(iu.getTouchpointData())); + manipulator.getConfigData().addBundle(bundleInfo); + assertTrue(isStartLevel(manipulator, osgiTarget, -1)); + + SetStartLevelAction action = new SetStartLevelAction(); + action.execute(parameters); + assertTrue(isStartLevel(manipulator, osgiTarget, -1)); + action.undo(parameters); + assertTrue(isStartLevel(manipulator, osgiTarget, -1)); + } + private boolean isStartLevel(Manipulator manipulator, File osgiTarget, int startLevel) { URI location = osgiTarget.toURI(); BundleInfo[] bundles = manipulator.getConfigData().getBundles(); diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java index 81212bca7..cab713288 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java @@ -182,6 +182,11 @@ public class Util { if (version == null) return null; bundleInfo.setVersion(version); + + String fragmentHost = (String) headers.get(Constants.FRAGMENT_HOST); + if (fragmentHost != null) + bundleInfo.setFragment(true); + } catch (BundleException e) { // unexpected LogHelper.log(new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e)); diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/MarkStartedAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/MarkStartedAction.java index 52f8484a1..f963255a3 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/MarkStartedAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/MarkStartedAction.java @@ -50,6 +50,9 @@ public class MarkStartedAction extends ProvisioningAction { if (bundleInfo == null) return Util.createError(NLS.bind(Messages.failed_bundleinfo, iu)); + if (bundleInfo.isFragment()) + return Status.OK_STATUS; + BundleInfo[] bundles = manipulator.getConfigData().getBundles(); for (int i = 0; i < bundles.length; i++) { if (bundles[i].equals(bundleInfo)) { @@ -62,6 +65,10 @@ public class MarkStartedAction extends ProvisioningAction { } public IStatus undo(Map parameters) { + Boolean previousStarted = (Boolean) getMemento().get(ActionConstants.PARM_PREVIOUS_STARTED); + if (previousStarted == null) + return Status.OK_STATUS; + IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE); Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR); IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU); @@ -85,9 +92,7 @@ public class MarkStartedAction extends ProvisioningAction { BundleInfo[] bundles = manipulator.getConfigData().getBundles(); for (int i = 0; i < bundles.length; i++) { if (bundles[i].equals(bundleInfo)) { - Boolean previousStarted = (Boolean) getMemento().get(ActionConstants.PARM_PREVIOUS_STARTED); - if (previousStarted != null) - bundles[i].setMarkedAsStarted(previousStarted.booleanValue()); + bundles[i].setMarkedAsStarted(previousStarted.booleanValue()); break; } } diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetStartLevelAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetStartLevelAction.java index 44cfc03c1..8a877802a 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetStartLevelAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetStartLevelAction.java @@ -49,6 +49,9 @@ public class SetStartLevelAction extends ProvisioningAction { if (bundleInfo == null) return Util.createError(NLS.bind(Messages.failed_bundleinfo, iu)); + if (bundleInfo.isFragment()) + return Status.OK_STATUS; + BundleInfo[] bundles = manipulator.getConfigData().getBundles(); for (int i = 0; i < bundles.length; i++) { if (bundles[i].equals(bundleInfo)) { @@ -65,6 +68,10 @@ public class SetStartLevelAction extends ProvisioningAction { } public IStatus undo(Map parameters) { + Integer previousStartLevel = (Integer) getMemento().get(ActionConstants.PARM_PREVIOUS_START_LEVEL); + if (previousStartLevel == null) + return Status.OK_STATUS; + IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE); Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR); IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU); @@ -88,9 +95,7 @@ public class SetStartLevelAction extends ProvisioningAction { BundleInfo[] bundles = manipulator.getConfigData().getBundles(); for (int i = 0; i < bundles.length; i++) { if (bundles[i].equals(bundleInfo)) { - Integer previousStartLevel = (Integer) getMemento().get(ActionConstants.PARM_PREVIOUS_START_LEVEL); - if (previousStartLevel != null) - bundles[i].setStartLevel(previousStartLevel.intValue()); + bundles[i].setStartLevel(previousStartLevel.intValue()); break; } } diff --git a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java index bf10877f9..99ed6beed 100644 --- a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java +++ b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java @@ -195,7 +195,7 @@ class ConfigApplier { } } else if (inDevMode && current.getBundleId() != 0 && current != manipulatingContext.getBundle() && !bundleLocation.equals(current.getLocation()) && !current.getLocation().startsWith("initial@")) { // We do not do this for the system bundle (id==0), the manipulating bundle or any bundle installed from the osgi.bundles list (locations starting with "@initial" - // The bundle exists; but the location is different. Unintall the current and install the new one (bug 229700) + // The bundle exists; but the location is different. Uninstall the current and install the new one (bug 229700) try { current.uninstall(); toRefresh.add(current); @@ -219,21 +219,28 @@ class ConfigApplier { continue; } } - int startLevel = finalList[i].getStartLevel(); - if (startLevel != BundleInfo.NO_LEVEL) - if (current.getBundleId() != 0) { - String name = current.getSymbolicName(); - try { - if (startLevel > 0) - if (!SimpleConfiguratorConstants.TARGET_CONFIGURATOR_NAME.equals(name)) - startLevelService.setBundleStartLevel(current, startLevel); - } catch (IllegalArgumentException ex) { - Utils.log(4, null, null, "Failed to set start level of Bundle:" + finalList[i], ex); //$NON-NLS-1$ - } - } + + // Mark Started if (finalList[i].isMarkedAsStarted()) { toStart.add(current); } + + // Set Start Level + int startLevel = finalList[i].getStartLevel(); + if (startLevel < 1) + continue; + if (current.getBundleId() == 0) + continue; + if (current.getHeaders().get(Constants.FRAGMENT_HOST) != null) + continue; + if (SimpleConfiguratorConstants.TARGET_CONFIGURATOR_NAME.equals(current.getSymbolicName())) + continue; + + try { + startLevelService.setBundleStartLevel(current, startLevel); + } catch (IllegalArgumentException ex) { + Utils.log(4, null, null, "Failed to set start level of Bundle:" + finalList[i], ex); //$NON-NLS-1$ + } } return toRefresh; } @@ -277,6 +284,8 @@ class ConfigApplier { Bundle bundle = bundles[i]; if (bundle.getState() == Bundle.STARTING && (bundle == callingBundle || bundle == manipulatingContext.getBundle())) continue; + if (bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null) + continue; try { bundle.start(); |