- Timestamp:
- 2006-10-07T01:57:23+02:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/plugins/PluginLoader.java
r151 r152 20 20 */ 21 21 public String loadClassName(File pluginFile) throws PluginException { 22 23 24 25 26 27 28 29 30 31 32 33 34 22 try { 23 JarInputStream jar = new JarInputStream(new FileInputStream(pluginFile)); 24 Manifest manifest = jar.getManifest(); 25 String pluginClass = manifest.getMainAttributes().getValue("Plugin-Class"); 26 jar.close(); 27 return pluginClass; 28 } catch (IOException e) { 29 String name = pluginFile.getName(); 30 if (name.endsWith(".jar")) 31 name = name.substring(0, name.length()-4); 32 throw new PluginException(null, name, e); 33 } 34 } 35 35 36 36 /** … … 42 42 name = name.substring(0, name.length()-4); 43 43 try { 44 String url = "file://"+pluginFile.getAbsolutePath(); 45 url = url.replace('\\', '/'); 46 47 // *sic* 48 if (System.getProperty("os.name").startsWith("Windows")) 49 url = "file:/" + url.substring(7); 50 44 51 ClassLoader loader = URLClassLoader.newInstance( 45 new URL[]{new URL( "file://"+pluginFile.getAbsolutePath())},52 new URL[]{new URL(url)}, 46 53 getClass().getClassLoader()); 47 54 Object plugin = Class.forName(pluginClass, true, loader).newInstance(); 48 55 return new PluginProxy(plugin, name); 49 50 51 56 } catch (Exception e) { 57 throw new PluginException(null, name, e); 58 } 52 59 } 53 60 }
Note:
See TracChangeset
for help on using the changeset viewer.