Changeset 167 in josm for src/org/openstreetmap/josm/plugins
- Timestamp:
- 2006-11-24T15:52:34+01:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/plugins/PluginInformation.java
r159 r167 6 6 import java.net.URL; 7 7 import java.net.URLClassLoader; 8 import java.util.ArrayList; 9 import java.util.List; 8 10 import java.util.Map; 9 11 import java.util.TreeMap; … … 25 27 public final boolean early; 26 28 public final String author; 29 public final List<URL> libraries = new ArrayList<URL>(); 27 30 28 31 public final Map<String, String> attr = new TreeMap<String, String>(); 29 32 33 /** 34 * @param file the plugin jar file. 35 */ 30 36 public PluginInformation(File file) { 31 37 this.file = file; … … 39 45 early = Boolean.parseBoolean(attr.getValue("Plugin-Early")); 40 46 author = attr.getValue("Author"); 47 libraries.add(new URL(getURLString(file.getAbsolutePath()))); 48 String classPath = attr.getValue("Class-Path"); 49 if (classPath != null) { 50 for (String s : classPath.split(classPath.contains(";") ? ";" : ":")) { 51 if (!s.startsWith("/") && !s.startsWith("\\") && !s.matches("^.:")) 52 s = file.getParent() + File.separator + s; 53 libraries.add(new URL(getURLString(s))); 54 } 55 } 56 41 57 for (Object o : attr.keySet()) 42 58 this.attr.put(o.toString(), attr.getValue(o.toString())); … … 63 79 public Class<?> loadClass() { 64 80 try { 65 ClassLoader loader = URLClassLoader.newInstance(66 new URL[]{new URL(getURLString())},67 81 URL[] urls = new URL[libraries.size()]; 82 urls = libraries.toArray(urls); 83 ClassLoader loader = URLClassLoader.newInstance(urls, getClass().getClassLoader()); 68 84 Class<?> realClass = Class.forName(className, true, loader); 69 85 return realClass; … … 73 89 } 74 90 75 private String getURLString( ) {91 private String getURLString(String fileName) { 76 92 if (System.getProperty("os.name").startsWith("Windows")) 77 return "file:/"+file .getAbsolutePath();78 return "file://"+file .getAbsolutePath();93 return "file:/"+fileName; 94 return "file://"+fileName; 79 95 } 80 96 }
Note:
See TracChangeset
for help on using the changeset viewer.