1 11 package org.eclipse.core.internal.plugins; 12 13 import java.io.IOException ; 14 import java.io.InputStream ; 15 import java.net.MalformedURLException ; 16 import java.net.URL ; 17 import java.util.*; 18 19 public class DevClassPathHelper { 20 static protected boolean inDevelopmentMode = false; 21 static protected String [] devDefaultClasspath; 22 static protected Properties devProperties = null; 23 24 static { 25 String osgiDev = System.getProperty("osgi.dev"); if (osgiDev != null) { 28 try { 29 inDevelopmentMode = true; 30 URL location = new URL (osgiDev); 31 devProperties = load(location); 32 devDefaultClasspath = getArrayFromList(devProperties.getProperty("*")); } catch (MalformedURLException e) { 34 devDefaultClasspath = getArrayFromList(osgiDev); 35 } 36 } 37 } 38 39 public static String [] getDevClassPath(String id) { 40 String [] result = null; 41 if (id != null && devProperties != null) { 42 String entry = devProperties.getProperty(id); 43 if (entry != null) 44 result = getArrayFromList(entry); 45 } 46 if (result == null) 47 result = devDefaultClasspath; 48 return result; 49 } 50 51 57 public static String [] getArrayFromList(String prop) { 58 if (prop == null || prop.trim().equals("")) return new String [0]; 60 Vector list = new Vector(); 61 StringTokenizer tokens = new StringTokenizer(prop, ","); while (tokens.hasMoreTokens()) { 63 String token = tokens.nextToken().trim(); 64 if (!token.equals("")) list.addElement(token); 66 } 67 return list.isEmpty() ? new String [0] : (String []) list.toArray(new String [list.size()]); 68 } 69 70 public static boolean inDevelopmentMode() { 71 return inDevelopmentMode; 72 } 73 74 77 private static Properties load(URL url) { 78 Properties props = new Properties(); 79 try { 80 InputStream is = null; 81 try { 82 is = url.openStream(); 83 props.load(is); 84 } finally { 85 if (is != null) 86 is.close(); 87 } 88 } catch (IOException e) { 89 } 91 return props; 92 } 93 } 94 | Popular Tags |