Modify

Opened 18 years ago

Closed 18 years ago

#116 closed enhancement (fixed)

Plugins dependencies

Reported by: frsantos@… Owned by: imi
Priority: major Milestone:
Component: unspecified Version:
Keywords: Cc:

Description

I am developing a plugin (ywms) that acts as a server for the WMS plugin, so I want to automagically configure this other plugin with default values first time on startup. Also, I need to reconfigure it every time the user changes some preferences.

So, I want to call some methods of the other plugin in mine, but I find that the load order of the plugins is not previsible. They are loaded in the order set in the preference "plugins", but this is set from a Map, which does not preserve any order. So my plugin may be loaded *before* the other plugin, and the class is not found to call any methods (by reflection).

As I can not relay on the "early" attribute to be set on any (not mine) plugin, or the order they are loaded, I need a way to inform that my plugin should be loaded *after* the other. Some kind of "Plugin-Dependencies" tag in the manifest that affects the load order may be useful.

Attachments (0)

Change History (2)

comment:1 by frsantos@…, 18 years ago

Also, it could be useful to be able to get other plugin object (ie, Main.getPlugin(name)) and other plugin preferences object (ie, Main.getPluginPreferences(name) while in the preferences dialog before the preferences are accepted.

comment:2 by imi, 18 years ago

Resolution: fixed
Status: newclosed

I've implemented an manifest-property "Plugin-Stage" which can be any number.

  • default is "50"
  • smaller numbers get loaded first
  • equal numbers are in an unspecified order (preference file order)
  • Plugin-Early are loaded before any other non-early plugin (in its own "stage-space")
  • The order of the plugins in the preference file is still arbitrary

So for your case, just set the manifest-attribute Plugin-Stage to 51 to have your plugin booted after the wms plugin.

As for the comment:1, the calls to PreferenceSetting#ok() are in the same order as the plugins registered themself in the preferences dialog, so if the other plugin is initialized earlier and if its register itself in its booting process, then it's ok() function will be called before yours. So just use the usual Main.pref.get() to access the updated preferences from the other plugin.

To get to other plugin informations: Main.plugins is a list of all loaded plugins (in the correct order).

PS: I know that this "cheap" solution could probably end up in a configuration mess where hundrets of angry plugin developer will riot because they work all day on figuring out what stage should be set for the plugin to not harm others in an complex and fragile plugin boot process... But until then, I don't care. :-)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain imi.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.