1 11 package org.eclipse.pde.internal.core; 12 13 import java.io.*; 14 import java.net.*; 15 import java.util.*; 16 17 import org.eclipse.core.internal.boot.*; 18 19 public class PlatformConfigurationUtils { 20 private static final String PLUGIN_PATH = ".plugin-path"; 22 27 public static URL[] getPluginPath(URL pluginPathLocation 28 ) { 29 InputStream input = null; 30 if (pluginPathLocation == null) 32 return null; 33 try { 34 input = pluginPathLocation.openStream(); 35 } catch (IOException e) { 36 } 38 39 if (input == null) 42 try { 43 URL url = new URL(PlatformURLBaseConnection.PLATFORM_URL_STRING + PLUGIN_PATH); 44 input = url.openStream(); 45 } catch (MalformedURLException e) { 46 } catch (IOException e) { 48 } 50 51 if (input == null) 53 return null; 54 URL[] result = null; 56 try { 57 try { 58 result = readPluginPath(input); 59 } finally { 60 input.close(); 61 } 62 } catch (IOException e) { 63 } 65 return result; 66 } 67 68 private static URL[] readPluginPath(InputStream input) { 69 Properties ini = new Properties(); 70 try { 71 ini.load(input); 72 } catch (IOException e) { 73 return null; 74 } 75 Vector result = new Vector(5); 76 for (Enumeration groups = ini.propertyNames(); groups.hasMoreElements();) { 77 String group = (String ) groups.nextElement(); 78 for (StringTokenizer entries = new StringTokenizer(ini.getProperty(group), ";"); entries.hasMoreElements();) { String entry = (String ) entries.nextElement(); 80 if (!entry.equals("")) try { 82 result.addElement(new URL(entry)); 83 } catch (MalformedURLException e) { 84 } 85 } 86 } 87 return (URL[]) result.toArray(new URL[result.size()]); 88 } 89 } 90 | Popular Tags |