Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 11 package org.eclipse.core.internal.runtime; 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 21 public static final String PROP_DEV = "osgi.dev"; 24 static protected boolean inDevelopmentMode = false; 25 static protected String [] devDefaultClasspath; 26 static protected Properties devProperties = null; 27 28 static { 29 String osgiDev = Activator.getContext() == null ? System.getProperty(PROP_DEV) : Activator.getContext().getProperty(PROP_DEV); 31 if (osgiDev != null) { 32 try { 33 inDevelopmentMode = true; 34 URL location = new URL (osgiDev); 35 devProperties = load(location); 36 if (devProperties != null) 37 devDefaultClasspath = getArrayFromList(devProperties.getProperty("*")); } catch (MalformedURLException e) { 39 devDefaultClasspath = getArrayFromList(osgiDev); 40 } 41 } 42 } 43 44 public static String [] getDevClassPath(String id) { 45 String [] result = null; 46 if (id != null && devProperties != null) { 47 String entry = devProperties.getProperty(id); 48 if (entry != null) 49 result = getArrayFromList(entry); 50 } 51 if (result == null) 52 result = devDefaultClasspath; 53 return result; 54 } 55 56 62 public static String [] getArrayFromList(String prop) { 63 if (prop == null || prop.trim().equals("")) return new String [0]; 65 Vector list = new Vector(); 66 StringTokenizer tokens = new StringTokenizer(prop, ","); while (tokens.hasMoreTokens()) { 68 String token = tokens.nextToken().trim(); 69 if (!token.equals("")) list.addElement(token); 71 } 72 return list.isEmpty() ? new String [0] : (String []) list.toArray(new String [list.size()]); 73 } 74 75 public static boolean inDevelopmentMode() { 76 return inDevelopmentMode; 77 } 78 79 82 private static Properties load(URL url) { 83 Properties props = new Properties(); 84 try { 85 InputStream is = null; 86 try { 87 is = url.openStream(); 88 props.load(is); 89 } finally { 90 if (is != null) 91 is.close(); 92 } 93 } catch (IOException e) { 94 } 96 return props; 97 } 98 } 99
| Popular Tags
|