diff options
author | John Arthorne | 2008-08-08 20:40:56 +0000 |
---|---|---|
committer | John Arthorne | 2008-08-08 20:40:56 +0000 |
commit | 612eb94f7f0bafe270cbb4fa5b5edf971462447e (patch) | |
tree | 61364d94a2dbaf4beb16bb5f9e0369fbd1718153 /bundles/org.eclipse.equinox.frameworkadmin.equinox | |
parent | 7a0997953bc009c18379bfe2b76722704410e2dc (diff) | |
download | rt.equinox.p2-612eb94f7f0bafe270cbb4fa5b5edf971462447e.tar.gz rt.equinox.p2-612eb94f7f0bafe270cbb4fa5b5edf971462447e.tar.xz rt.equinox.p2-612eb94f7f0bafe270cbb4fa5b5edf971462447e.zip |
Add getKey helper method to simplify name/version state index code
Diffstat (limited to 'bundles/org.eclipse.equinox.frameworkadmin.equinox')
-rw-r--r-- | bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxBundlesState.java | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxBundlesState.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxBundlesState.java index 3d4cdbf6d..599399ac6 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxBundlesState.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxBundlesState.java @@ -234,7 +234,16 @@ public class EquinoxBundlesState implements BundlesState { StateObjectFactory soFactory = null; State state = null; + + /** + * Map of String->BundleDescription, where the key is the bundle location. + */ private HashMap locationStateIndex = new HashMap(); + + /** + * Map of String->BundleDescription, where the key is the bundle name + * and version as defined by the {@link #getKey(BundleDescription)} method. + */ private HashMap nameVersionStateIndex = new HashMap(); /** @@ -669,8 +678,6 @@ public class EquinoxBundlesState implements BundlesState { if (soFactory != null) return; PlatformAdmin platformAdmin = (PlatformAdmin) Activator.acquireService(PlatformAdmin.class.getName()); - // PlatformAdmin platformAdmin = (PlatformAdmin) - // heBundleHelper.getDefault().acquireService(PlatformAdmin.class.getName()); soFactory = platformAdmin.getFactory(); } @@ -736,15 +743,20 @@ public class EquinoxBundlesState implements BundlesState { return (BundleDescription) nameVersionStateIndex.get(bundleSymbolicName + ";" + bundleVersion); } + /** + * Returns a key for a bundle description containing the bundle name and version, + * for use in the name/version state index map. + */ + private String getKey(BundleDescription bundle) { + return bundle.getSymbolicName() + ';' + bundle.getVersion(); + } + private void createStateIndexes() { BundleDescription[] currentInstalledBundles = state.getBundles(); for (int i = 0; i < currentInstalledBundles.length; i++) { String location = FileUtils.getRealLocation(manipulator, currentInstalledBundles[i].getLocation(), true); locationStateIndex.put(location, currentInstalledBundles[i]); - - String symbolicName = currentInstalledBundles[i].getSymbolicName(); - String version = currentInstalledBundles[i].getVersion().toString(); - nameVersionStateIndex.put(symbolicName + ";" + version, currentInstalledBundles[i]); //$NON-NLS-1$ + nameVersionStateIndex.put(getKey(currentInstalledBundles[i]), currentInstalledBundles[i]); } } @@ -752,19 +764,13 @@ public class EquinoxBundlesState implements BundlesState { state.addBundle(bundleDescription); String location = FileUtils.getRealLocation(manipulator, bundleDescription.getLocation(), true); locationStateIndex.put(location, bundleDescription); - - String symbolicName = bundleDescription.getSymbolicName(); - String version = bundleDescription.getVersion().toString(); - nameVersionStateIndex.put(symbolicName + ";" + version, bundleDescription); //$NON-NLS-1$ + nameVersionStateIndex.put(getKey(bundleDescription), bundleDescription); } private void removeBundleFromState(BundleDescription bundleDescription) { String location = FileUtils.getRealLocation(manipulator, bundleDescription.getLocation(), true); locationStateIndex.remove(location); - - String symbolicName = bundleDescription.getSymbolicName(); - String version = bundleDescription.getVersion().toString(); - nameVersionStateIndex.remove(symbolicName + ";" + version); //$NON-NLS-1$ + nameVersionStateIndex.remove(getKey(bundleDescription)); state.removeBundle(bundleDescription); } } |