1 11 package org.eclipse.osgi.internal.baseadaptor; 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 import org.eclipse.osgi.framework.internal.core.FrameworkProperties; 19 import org.eclipse.osgi.util.ManifestElement; 20 21 25 public final class DevClassPathHelper { 26 static private boolean inDevelopmentMode = false; 27 static private String [] devDefaultClasspath; 28 static private Dictionary devProperties = null; 29 30 static { 31 String osgiDev = FrameworkProperties.getProperty("osgi.dev"); if (osgiDev != null) { 34 try { 35 inDevelopmentMode = true; 36 URL location = new URL (osgiDev); 37 devProperties = load(location); 38 if (devProperties != null) 39 devDefaultClasspath = getArrayFromList((String ) devProperties.get("*")); } catch (MalformedURLException e) { 41 devDefaultClasspath = getArrayFromList(osgiDev); 42 } 43 } 44 } 45 46 private static String [] getDevClassPath(String id, Dictionary properties, String [] defaultClasspath) { 47 String [] result = null; 48 if (id != null && properties != null) { 49 String entry = (String ) properties.get(id); 50 if (entry != null) 51 result = getArrayFromList(entry); 52 } 53 if (result == null) 54 result = defaultClasspath; 55 return result; 56 } 57 58 65 public static String [] getDevClassPath(String id, Dictionary properties) { 66 if (properties == null) 67 return getDevClassPath(id, devProperties, devDefaultClasspath); 68 return getDevClassPath(id, properties, getArrayFromList((String ) properties.get("*"))); } 70 71 76 public static String [] getDevClassPath(String id) { 77 return getDevClassPath(id, null); 78 } 79 80 86 public static String [] getArrayFromList(String prop) { 87 return ManifestElement.getArrayFromList(prop, ","); } 89 90 94 public static boolean inDevelopmentMode() { 95 return inDevelopmentMode; 96 } 97 98 101 private static Properties load(URL url) { 102 Properties props = new Properties(); 103 try { 104 InputStream is = null; 105 try { 106 is = url.openStream(); 107 props.load(is); 108 } finally { 109 if (is != null) 110 is.close(); 111 } 112 } catch (IOException e) { 113 } 115 return props; 116 } 117 } 118 | Popular Tags |