diff options
author | Andrew Niefer | 2009-08-26 17:39:38 +0000 |
---|---|---|
committer | Andrew Niefer | 2009-08-26 17:39:38 +0000 |
commit | b86a88a6f65be18564e256dafa474d455186f6ca (patch) | |
tree | fe546032537b9815b4597c2830541f522ad7b9bf /bundles/org.eclipse.equinox.p2.publisher | |
parent | a1083588e0ebad9d4f079aabe88219ff424d9df5 (diff) | |
download | rt.equinox.p2-b86a88a6f65be18564e256dafa474d455186f6ca.tar.gz rt.equinox.p2-b86a88a6f65be18564e256dafa474d455186f6ca.tar.xz rt.equinox.p2-b86a88a6f65be18564e256dafa474d455186f6ca.zip |
bug 287703 - Use SimpleConfiguratorManipulator to read bundles.info
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.publisher')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF | 1 | ||||
-rw-r--r-- | bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/eclipse/DataLoader.java | 92 |
2 files changed, 6 insertions, 87 deletions
diff --git a/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF index fe8862e12..6b78c2e87 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF @@ -25,6 +25,7 @@ Import-Package: javax.xml.parsers, org.eclipse.equinox.internal.provisional.p2.metadata.repository, org.eclipse.equinox.internal.provisional.p2.query, org.eclipse.equinox.internal.provisional.p2.repository, + org.eclipse.equinox.internal.provisional.simpleconfigurator.manipulator, org.eclipse.osgi.service.environment;version="1.1.0", org.eclipse.osgi.service.pluginconversion;version="1.0.0", org.eclipse.osgi.service.resolver;version="1.2.0", diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/eclipse/DataLoader.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/eclipse/DataLoader.java index dc1d5f372..254d93c12 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/eclipse/DataLoader.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/eclipse/DataLoader.java @@ -9,18 +9,18 @@ ******************************************************************************/ package org.eclipse.equinox.internal.p2.publisher.eclipse; -import java.io.*; +import java.io.File; +import java.io.IOException; import java.net.*; -import java.util.*; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxFwConfigFileParser; import org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxManipulatorImpl; -import org.eclipse.equinox.internal.frameworkadmin.utils.Utils; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.publisher.Activator; import org.eclipse.equinox.internal.provisional.frameworkadmin.*; +import org.eclipse.equinox.internal.provisional.simpleconfigurator.manipulator.SimpleConfiguratorManipulator; import org.osgi.framework.*; import org.osgi.service.packageadmin.PackageAdmin; @@ -36,93 +36,10 @@ public class DataLoader { private static final String ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR_CONFIGURL = "org.eclipse.equinox.simpleconfigurator.configUrl"; //$NON-NLS-1$ private static final String ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR_MANIPULATOR = "org.eclipse.equinox.simpleconfigurator.manipulator"; //$NON-NLS-1$ private static final String ORG_ECLIPSE_EQUINOX_FRAMEWORKADMIN_EQUINOX = "org.eclipse.equinox.frameworkadmin.equinox"; //$NON-NLS-1$ - private static final String PARAMETER_BASEURL = "org.eclipse.equinox.simpleconfigurator.baseUrl"; //$NON-NLS-1$ private Manipulator manipulator; private File configurationLocation; - public static BundleInfo[] readConfiguration(URL url) throws IOException { - List bundles = new ArrayList(); - try { - // System.out.println("readConfiguration(URL url):url()=" + url); - // URL configFileUrl = getConfigFileUrl(); - // URL configFileUrl = Utils.getUrl("file",null, - // inputFile.getAbsolutePath()); - BufferedReader r = new BufferedReader(new InputStreamReader(url.openStream())); - // BufferedReader r = new BufferedReader(new FileReader(inputFile)); - - String line; - try { - URL baseUrl = new URL(url, "./"); //$NON-NLS-1$ - while ((line = r.readLine()) != null) { - if (line.startsWith("#")) //$NON-NLS-1$ - continue; - line = line.trim();// symbolicName,version,location,startlevel,expectedState - if (line.length() == 0) - continue; - - // (expectedState is an integer). - if (line.startsWith(PARAMETER_BASEURL + "=")) { //$NON-NLS-1$ - String baseUrlSt = line.substring((PARAMETER_BASEURL + "=").length()); //$NON-NLS-1$ - if (!baseUrlSt.endsWith("/")) //$NON-NLS-1$ - baseUrlSt += "/"; //$NON-NLS-1$ - baseUrl = new URL(url, baseUrlSt); - continue; - } - StringTokenizer tok = new StringTokenizer(line, ",", true); //$NON-NLS-1$ - String symbolicName = tok.nextToken(); - if (symbolicName.equals(",")) //$NON-NLS-1$ - symbolicName = null; - else - tok.nextToken(); // , - - String version = tok.nextToken(); - if (version.equals(",")) //$NON-NLS-1$ - version = null; - else - tok.nextToken(); // , - - String urlSt = tok.nextToken(); - if (urlSt.equals(",")) { //$NON-NLS-1$ - if (symbolicName != null && version != null) - urlSt = symbolicName + "_" + version + ".jar"; //$NON-NLS-1$ //$NON-NLS-2$ - else - urlSt = null; - } else - tok.nextToken(); // , - try { - new URL(urlSt); - } catch (MalformedURLException e) { - urlSt = Utils.getUrlInFull(urlSt, baseUrl).toExternalForm(); - } - - int sl = Integer.parseInt(tok.nextToken().trim()); - tok.nextToken(); // , - boolean markedAsStarted = Boolean.valueOf(tok.nextToken()).booleanValue(); - - BundleInfo bInfo; - try { - bInfo = new BundleInfo(symbolicName, version, new URI(urlSt), sl, markedAsStarted); - - bundles.add(bInfo); - } catch (URISyntaxException e) { - e.printStackTrace(); - throw new IllegalStateException("Error coverting url based string to uri: " + e.getMessage()); - } - } - } finally { - try { - r.close(); - } catch (IOException ex) { - // ignore - } - } - } catch (MalformedURLException e) { - // TODO log something - } - return (BundleInfo[]) bundles.toArray(new BundleInfo[bundles.size()]); - } - /** * * @param configurationLocation configuration file (i.e. config.ini). @@ -171,7 +88,8 @@ public class DataLoader { if (value != null) { try { //config.ini uses simpleconfigurator, read the bundles.info and replace the bundle infos - BundleInfo[] bundleInfos = readConfiguration(new URL(value)); + SimpleConfiguratorManipulator simpleManipulator = (SimpleConfiguratorManipulator) ServiceHelper.getService(Activator.getContext(), SimpleConfiguratorManipulator.class.getName()); + BundleInfo[] bundleInfos = simpleManipulator.loadConfiguration(new URL(value), null); data.setBundles(bundleInfos); } catch (MalformedURLException e1) { // ignore |