diff options
author | Pascal Rapicault | 2008-02-29 20:53:32 +0000 |
---|---|---|
committer | Pascal Rapicault | 2008-02-29 20:53:32 +0000 |
commit | ffab9e3a89c0543706e4c49e162d3ad3c1a5a60a (patch) | |
tree | f6b2e66ad31fdae426fa60ac1afd0e5a110bfb53 | |
parent | a0ab56607c409d1b6362f0c5145cb2ce6decaf44 (diff) | |
download | rt.equinox.p2-ffab9e3a89c0543706e4c49e162d3ad3c1a5a60a.tar.gz rt.equinox.p2-ffab9e3a89c0543706e4c49e162d3ad3c1a5a60a.tar.xz rt.equinox.p2-ffab9e3a89c0543706e4c49e162d3ad3c1a5a60a.zip |
Improve resilience of launcher location computation
2 files changed, 54 insertions, 5 deletions
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java index b7655d4bf..d04e47b76 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java @@ -378,13 +378,21 @@ public class EquinoxFwConfigFileParser { return null; for (int i = 0; i < args.length; i++) { if (args[i].equals("-startup") && i + 1 < args.length && args[i + 1].charAt(1) != '-') { //$NON-NLS-1$ - IPath parentFolder = new Path(args[i + 1]).removeLastSegments(1); - if (parentFolder.lastSegment().equals("plugins")) //$NON-NLS-1$ - return parentFolder.removeLastSegments(1).toFile(); - return parentFolder.toFile(); + return fromOSGiJarToOSGiInstallArea(args[i + 1]); } } - return launcherData.getLauncher().getParentFile(); + if (launcherData.getFwJar() != null) + return fromOSGiJarToOSGiInstallArea(launcherData.getFwJar().getAbsolutePath()); + if (launcherData.getLauncher() != null) + return launcherData.getLauncher().getParentFile(); + return null; + } + + private static File fromOSGiJarToOSGiInstallArea(String path) { + IPath parentFolder = new Path(path).removeLastSegments(1); + if (parentFolder.lastSegment().equals("plugins")) //$NON-NLS-1$ + return parentFolder.removeLastSegments(1).toFile(); + return parentFolder.toFile(); } public void saveFwConfig(BundleInfo[] bInfos, Manipulator manipulator, boolean backup, boolean relative) throws IOException {//{ diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestRunningInstance.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestRunningInstance.java new file mode 100644 index 000000000..f8476238f --- /dev/null +++ b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestRunningInstance.java @@ -0,0 +1,41 @@ +package org.eclipse.equinox.frameworkadmin.tests; + +import org.eclipse.equinox.internal.provisional.frameworkadmin.*; +import org.osgi.framework.*; + +public class TestRunningInstance extends AbstractFwkAdminTest { + + public TestRunningInstance(String name) { + super(name); + } + + public void testRunningInstance() throws BundleException { + FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); + Manipulator m = fwkAdmin.getRunningManipulator(); + BundleInfo[] infos = m.getConfigData().getBundles(); + for (int i = 0; i < infos.length; i++) { + System.out.println(infos[i]); + } + + Bundle[] bundles = Activator.getContext().getBundles(); + + assertEquals(bundles.length, infos.length); + for (int i = 0; i < bundles.length; i++) { + boolean found = false; + for (int j = 0; j < infos.length && found == false; j++) { + found = same(infos[j], bundles[i]); + } + if (found == false) { + fail("Can't find: " + bundles[i]); + } + } + } + + private boolean same(BundleInfo info, Bundle bundle) { + if (info.getSymbolicName().equals(bundle.getSymbolicName())) { + if (new Version((String) bundle.getHeaders().get(Constants.BUNDLE_VERSION)).equals(new Version(info.getVersion()))) + return true; + } + return false; + } +} |