Changeset 3070 in josm


Ignore:
Timestamp:
2010-03-02T20:55:48+01:00 (9 years ago)
Author:
Gubaer
Message:

Removing @deprecated support for former ugly hacks in the plugin handling. Plugins in OSM SVN are migrated.

Location:
trunk/src/org/openstreetmap/josm/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/Plugin.java

    r2927 r3070  
    4646    private PluginInformation info = null;
    4747
    48     /**
    49      * The no-arg constructor is deprecated.
    50      *
    51      * @deprecated use {@see Plugin(PluginInformation)} instead
    52      */
    53     @Deprecated
    54     public Plugin() {
    55 
    56     }
    5748    /**
    5849     * Creates the plugin
  • trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java

    r2934 r3070  
    1010import java.lang.reflect.Constructor;
    1111import java.lang.reflect.InvocationTargetException;
    12 import java.lang.reflect.Method;
    1312import java.net.MalformedURLException;
    1413import java.net.URL;
     
    193192    public PluginProxy load(Class<?> klass) throws PluginException{
    194193        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);
    219196            return new PluginProxy(plugin, this);
    220197        } catch(NoSuchMethodException e) {
Note: See TracChangeset for help on using the changeset viewer.