Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2010-12-02 15:17:22 -0500
committerDJ Houghton2010-12-02 15:17:22 -0500
commit354283b6def3aee6286d63f9cde257acfae4d404 (patch)
tree5d317499b5cd57f94cf430615888c22ee41dcf21 /bundles/org.eclipse.equinox.p2.touchpoint.eclipse
parent2be782b8fc40f4742827bcab9185dbbb31e8fb3d (diff)
downloadrt.equinox.p2-354283b6def3aee6286d63f9cde257acfae4d404.tar.gz
rt.equinox.p2-354283b6def3aee6286d63f9cde257acfae4d404.tar.xz
rt.equinox.p2-354283b6def3aee6286d63f9cde257acfae4d404.zip
Bug 329386 - Optimize manifest TouchPointData memory footprint for MetadataRepositories
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.eclipse')
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java81
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/InstallBundleAction.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/MarkStartedAction.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetStartLevelAction.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/UninstallBundleAction.java8
6 files changed, 48 insertions, 79 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF
index 4c3b5fc95..629fc0cd2 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF
@@ -20,6 +20,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.internal.p2.core.helpers,
org.eclipse.equinox.internal.p2.engine,
org.eclipse.equinox.internal.p2.garbagecollector,
+ org.eclipse.equinox.internal.p2.metadata,
org.eclipse.equinox.internal.provisional.frameworkadmin,
org.eclipse.equinox.internal.provisional.p2.repository,
org.eclipse.equinox.internal.simpleconfigurator.manipulator,
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 9d80ed320..982e90f21 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
@@ -12,12 +12,14 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;
-import java.io.*;
+import java.io.File;
+import java.io.IOException;
import java.net.*;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.p2.core.helpers.*;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.p2.core.*;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.metadata.*;
@@ -25,10 +27,7 @@ import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.artifact.*;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.environment.EnvironmentInfo;
-import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
public class Util {
@@ -157,42 +156,48 @@ public class Util {
return listProperty;
}
- public static BundleInfo createBundleInfo(File bundleFile, String manifest) {
+ public static BundleInfo createBundleInfo(File bundleFile, IInstallableUnit unit) {
BundleInfo bundleInfo = new BundleInfo();
if (bundleFile != null)
bundleInfo.setLocation(bundleFile.toURI());
- bundleInfo.setManifest(manifest);
- try {
- Map<String, String> headers = ManifestElement.parseBundleManifest(new ByteArrayInputStream(manifest.getBytes("UTF-8")), new HashMap<String, String>()); //$NON-NLS-1$
- ManifestElement[] element = ManifestElement.parseHeader("bsn", headers.get(Constants.BUNDLE_SYMBOLICNAME)); //$NON-NLS-1$
- if (element == null || element.length == 0)
- return null;
- bundleInfo.setSymbolicName(element[0].getValue());
-
- String version = headers.get(Constants.BUNDLE_VERSION);
- if (version == null)
- return null;
- // convert to a Version object first to ensure we are consistent with our version number w.r.t.
- // padding zeros at the end
- bundleInfo.setVersion(Version.parseVersion(version).toString());
-
- String fragmentHost = headers.get(Constants.FRAGMENT_HOST);
- if (fragmentHost != null)
- bundleInfo.setFragmentHost(fragmentHost.trim());
-
- } catch (BundleException e) {
- // unexpected
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e));
- return null;
- } catch (IOException e) {
- // unexpected
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e));
- return null;
+ Collection<IProvidedCapability> capabilities = unit.getProvidedCapabilities();
+ for (IProvidedCapability capability : capabilities) {
+ String nameSpace = capability.getNamespace();
+ if (nameSpace.equals("osgi.bundle")) { //$NON-NLS-1$
+ bundleInfo.setSymbolicName(capability.getName());
+ bundleInfo.setVersion(capability.getVersion().toString());
+ } else if (nameSpace.equals("osgi.fragment")) { //$NON-NLS-1$
+ String fragmentName = capability.getName();
+ String fragmentHost = getFragmentHost(unit, fragmentName);
+ // shouldn't happen as long as the metadata is well-formed
+ if (fragmentHost == null)
+ LogHelper.log(createError("Unable to find fragment host for IU: " + unit)); //$NON-NLS-1$
+ else
+ bundleInfo.setFragmentHost(fragmentHost);
+ bundleInfo.setVersion(capability.getVersion().toString());
+ }
}
return bundleInfo;
}
+ private static String getFragmentHost(IInstallableUnit unit, String fragmentName) {
+ Collection<IRequirement> requires = unit.getRequirements();
+ for (IRequirement iRequirement : requires) {
+ if (iRequirement instanceof IRequiredCapability) {
+ IRequiredCapability requiredCapability = (IRequiredCapability) iRequirement;
+ if (fragmentName.equals(requiredCapability.getName())) {
+ String fragmentHost = requiredCapability.getName();
+ if (!requiredCapability.getRange().toString().equals("0.0.0")) { //$NON-NLS-1$
+ fragmentHost += ";bundle-version=\"" + requiredCapability.getRange() + '"'; //$NON-NLS-1$
+ }
+ return fragmentHost;
+ }
+ }
+ }
+ return null;
+ }
+
public static File getArtifactFile(IProvisioningAgent agent, IArtifactKey artifactKey, IProfile profile) {
IFileArtifactRepository aggregatedView = getAggregatedBundleRepository(agent, profile);
File bundleJar = aggregatedView.getArtifactFile(artifactKey);
@@ -313,18 +318,6 @@ public class Util {
return null;
}
- public static String getManifest(Collection<ITouchpointData> data) {
- for (ITouchpointData td : data) {
- ITouchpointInstruction manifestInstruction = td.getInstruction("manifest"); //$NON-NLS-1$
- if (manifestInstruction == null)
- return null;
- String manifest = manifestInstruction.getBody();
- if (manifest != null && manifest.length() > 0)
- return manifest;
- }
- return null;
- }
-
public static IStatus createError(String message) {
return createError(message, null);
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/InstallBundleAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/InstallBundleAction.java
index fab1f90b7..4a2ecfe99 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/InstallBundleAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/InstallBundleAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others. All rights reserved. This
+ * Copyright (c) 2008, 2010 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 http://www.eclipse.org/legal/epl-v10.html
@@ -69,12 +69,7 @@ public class InstallBundleAction extends ProvisioningAction {
if (bundleFile == null || !bundleFile.exists())
return Util.createError(NLS.bind(Messages.artifact_file_not_found, artifactKey));
- //By now we always have the manifest in the touchpoint data
- String manifest = Util.getManifest(iu.getTouchpointData());
- if (manifest == null)
- return Util.createError(NLS.bind(Messages.missing_manifest, iu));
-
- BundleInfo bundleInfo = Util.createBundleInfo(bundleFile, manifest);
+ BundleInfo bundleInfo = Util.createBundleInfo(bundleFile, iu);
if (bundleInfo == null)
return Util.createError(NLS.bind(Messages.failed_bundleinfo, iu));
manipulator.getConfigData().addBundle(bundleInfo);
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 52e1f68d4..832c147ad 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2010 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
@@ -47,11 +47,7 @@ public class MarkStartedAction extends ProvisioningAction {
// the bundleFile might be null here, that's OK.
File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
- String manifest = Util.getManifest(iu.getTouchpointData());
- if (manifest == null)
- return Util.createError(NLS.bind(Messages.missing_manifest, iu));
-
- BundleInfo bundleInfo = Util.createBundleInfo(bundleFile, manifest);
+ BundleInfo bundleInfo = Util.createBundleInfo(bundleFile, iu);
if (bundleInfo == null)
return Util.createError(NLS.bind(Messages.failed_bundleinfo, iu));
@@ -87,11 +83,7 @@ public class MarkStartedAction extends ProvisioningAction {
// the bundleFile might be null here, that's OK.
File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
- String manifest = Util.getManifest(iu.getTouchpointData());
- if (manifest == null)
- return Util.createError(NLS.bind(Messages.missing_manifest, iu));
-
- BundleInfo bundleInfo = Util.createBundleInfo(bundleFile, manifest);
+ BundleInfo bundleInfo = Util.createBundleInfo(bundleFile, iu);
if (bundleInfo == null)
return Util.createError(NLS.bind(Messages.failed_bundleinfo, iu));
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 9d2f3c456..9452c7172 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2010 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
@@ -46,11 +46,7 @@ public class SetStartLevelAction extends ProvisioningAction {
// the bundleFile might be null here, that's OK.
File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
- String manifest = Util.getManifest(iu.getTouchpointData());
- if (manifest == null)
- return Util.createError(NLS.bind(Messages.missing_manifest, iu));
-
- BundleInfo bundleInfo = Util.createBundleInfo(bundleFile, manifest);
+ BundleInfo bundleInfo = Util.createBundleInfo(bundleFile, iu);
if (bundleInfo == null)
return Util.createError(NLS.bind(Messages.failed_bundleinfo, iu));
@@ -90,11 +86,7 @@ public class SetStartLevelAction extends ProvisioningAction {
// the bundleFile might be null here, that's OK.
File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
- String manifest = Util.getManifest(iu.getTouchpointData());
- if (manifest == null)
- return Util.createError(NLS.bind(Messages.missing_manifest, iu));
-
- BundleInfo bundleInfo = Util.createBundleInfo(bundleFile, manifest);
+ BundleInfo bundleInfo = Util.createBundleInfo(bundleFile, iu);
if (bundleInfo == null)
return Util.createError(NLS.bind(Messages.failed_bundleinfo, iu));
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/UninstallBundleAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/UninstallBundleAction.java
index 0d4070995..a20aae951 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/UninstallBundleAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/UninstallBundleAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others. All rights reserved. This
+ * Copyright (c) 2008, 2010 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 http://www.eclipse.org/legal/epl-v10.html
@@ -68,11 +68,7 @@ public class UninstallBundleAction extends ProvisioningAction {
// the bundleFile might be null here, that's OK.
File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
- String manifest = Util.getManifest(iu.getTouchpointData());
- if (manifest == null)
- return Util.createError(NLS.bind(Messages.missing_manifest, iu));
-
- BundleInfo bundleInfo = Util.createBundleInfo(bundleFile, manifest);
+ BundleInfo bundleInfo = Util.createBundleInfo(bundleFile, iu);
if (bundleInfo == null)
return Util.createError(NLS.bind(Messages.failed_bundleinfo, iu));
manipulator.getConfigData().removeBundle(bundleInfo);

Back to the top