Changeset 5241 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2012-05-18T12:45:10+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/Plugin.java
r3530 r5241 7 7 import java.io.IOException; 8 8 import java.io.InputStream; 9 import java.net.URL; 10 import java.net.URLClassLoader; 9 11 import java.util.List; 10 12 … … 117 119 out.close(); 118 120 } 121 122 /** 123 * Get a class loader for loading resources from the plugin jar. 124 * 125 * This can be used to avoid getting a file from another plugin that 126 * happens to have a file with the same file name and path. 127 * 128 * Usage: Instead of 129 * getClass().getResource("/resources/pluginProperties.properties"); 130 * write 131 * getPluginResourceClassLoader().getResource("resources/pluginProperties.properties"); 132 * 133 * (Note the missing leading "/".) 134 */ 135 public ClassLoader getPluginResourceClassLoader() { 136 File pluginDir = Main.pref.getPluginsDirectory(); 137 File pluginJar = new File(pluginDir, info.name + ".jar"); 138 URL pluginJarUrl = PluginInformation.fileToURL(pluginJar); 139 URLClassLoader pluginClassLoader = new URLClassLoader(new URL[] { pluginJarUrl } , Main.class.getClassLoader()); 140 return pluginClassLoader; 141 } 119 142 }
Note:
See TracChangeset
for help on using the changeset viewer.