Changeset 3070 in josm for trunk/src/org/openstreetmap/josm/plugins
- Timestamp:
- 2010-03-02T20:55:48+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/plugins
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/Plugin.java
r2927 r3070 46 46 private PluginInformation info = null; 47 47 48 /**49 * The no-arg constructor is deprecated.50 *51 * @deprecated use {@see Plugin(PluginInformation)} instead52 */53 @Deprecated54 public Plugin() {55 56 }57 48 /** 58 49 * Creates the plugin -
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r2934 r3070 10 10 import java.lang.reflect.Constructor; 11 11 import java.lang.reflect.InvocationTargetException; 12 import java.lang.reflect.Method;13 12 import java.net.MalformedURLException; 14 13 import java.net.URL; … … 193 192 public PluginProxy load(Class<?> klass) throws PluginException{ 194 193 try { 195 try { 196 Constructor<?> c = klass.getConstructor(PluginInformation.class); 197 Object plugin = c.newInstance(this); 198 return new PluginProxy(plugin, this); 199 } catch(NoSuchMethodException e) { 200 // do nothing - try again with the noarg constructor for legacy support 201 } catch(InstantiationException e) { 202 // do nothing - try again with the noarg constructor for legacy support 203 } 204 // FIXME: This is legacy support. It is necessary because of a former ugly hack in the 205 // plugin bootstrap procedure. Plugins should be migrated to the new required 206 // constructor with PluginInformation as argument, new plugins should only use this 207 // constructor. The following is legacy support and should be removed by Q2/2010. 208 // Note that this is not fool proof because it isn't 209 // completely equivalent with the former hack: plugins derived from the Plugin 210 // class can't access their local "info" object any more from within the noarg- 211 // constructor. It is only set *after* constructor invocation. 212 // 213 Constructor<?> c = klass.getConstructor(); 214 Object plugin = c.newInstance(); 215 if (plugin instanceof Plugin) { 216 Method m = klass.getMethod("setPluginInformation", PluginInformation.class); 217 m.invoke(plugin, this); 218 } 194 Constructor<?> c = klass.getConstructor(PluginInformation.class); 195 Object plugin = c.newInstance(this); 219 196 return new PluginProxy(plugin, this); 220 197 } catch(NoSuchMethodException e) {
Note:
See TracChangeset
for help on using the changeset viewer.