
Vojtech, Please go ahead and include my ideas and/or code into your next patch. With regards to the FIXME, I think using the 'date last modified' is a good idea. However, the plugin descriptor file can also reference the plugin config file (via the configFile property). I imagine that adding, removing or reconfiguring plugins will be a relatively rare event, so maybe there is a simpler method: Remember the newest timestamp of ($DATADIR/ui-plugins/*, $CONFIGDIR/ui-plugins/*) and reload the plugin descriptors and configurations if the newest timestamp changes. As far as synchronization goes, the current code's getPluginDefinitions() loads all of the plugin descriptors and configurations into a new HashMap and then assigns that hashmap to WebadminDynamicHostingServlet.pluginDefinitions. As long as the JsonNode trees in pluginDefinitions aren't modified after being put into pluginDefinitions, I don't see a synchronization issue. Successive calls to get data from the pluginDefinitions hashmap may see different data, but they'll never see inconsistent data (e.g. a partially constructed plugin descriptor). However, if we want to add calls to modify the pluginDefinitions at runtime (such as a element in the GUI that disables certain plugins), then we will need synchronization. We'll also have to concern ourselves with whether any such modifications need to be saved back to the files on disk. --Chris -----Original Message----- From: Vojtech Szocs [mailto:vszocs@redhat.com] Sent: Tuesday, September 04, 2012 7:46 AM To: Frantz, Chris Cc: engine-devel Subject: Re: UI Plugins configuration Thank you Chris :) I'd like to incorporate your ideas into upcoming PoC patch, which will be focused on server-side components of UI plugin infrastructure: 1) servlet that serves plugin-related static resources (plugin host page, actual plugin code, any 3rd party JavaScript libraries, CSS, etc.) from local filesystem 2) class responsible for parsing/validating/caching plugin descriptor information from local filesystem Regarding the comment in WebadminDynamicHostingServlet that says "FIXME: do we load this everytime, or just once?": maybe we could use the same approach as in servlet containers, which use 'date last modified' attribute of JSP files to trigger recompilation of corresponding servlets. For example, each time WebAdmin host page gets requested through WebadminDynamicHostingServlet, we could iterate over plugin descriptor files (in /usr/share/ovirt-engine/ui-plugins), looking at 'date last modified' attribute, parsing/validating plugin meta-data, and caching it using pluginName + dateLastModified (compound cache key). We also need to synchronize the access to plugin meta-data. What do you think? After the upcoming PoC patch (focused on server-side components) gets released, UI plugin infrastructure should be pretty much stable and we can focus on adding particular features, such as: * adding custom sub-tabs * adding custom context-menu items * making REST API calls through plugin API * investigating cross-origin plugin scenario (plugin gets loaded from page sitting on different origin than Engine JBoss instance) Let me know what you think. Cheers, Vojtech ----- Original Message ----- From: "Chris Frantz" <Chris.Frantz@hp.com> To: "Vojtech Szocs" <vszocs@redhat.com> Cc: "engine-devel" <engine-devel@ovirt.org> Sent: Thursday, August 30, 2012 10:03:02 PM Subject: RE: UI Plugins configuration Vojtech, Here is my patch against WIP-UI-Plugins-PoC-revision-4. I’ve also included 2 dummy plugins in sample.tar.gz. --Chris From: engine-devel-bounces@ovirt.org [mailto:engine-devel-bounces@ovirt.org] On Behalf Of Frantz, Chris Sent: Thursday, August 30, 2012 1:06 PM To: Vojtech Szocs Cc: engine-devel Subject: Re: [Engine-devel] UI Plugins configuration Vojtech, I agree with your formalized names: Plugin Descriptor is the JSON file containing plugin meta-data. The plugin descriptor may also contain the default configuration data. It is located in $DATADIR/ui-plugins. Plugin Configuration is the JSON file containing optional plugin configuration info. It is located in $CONFIGDIR/ui-plugins (unless the Plugin Descriptor contains an absolute path). Plugin Definition is the JavaScript object used by WebAdmin. In the current implementation, the Plugin Definition contains both the Plugin Descriptor and the Plugin Configuraion. Plugin Source Page is the HTML page used to invoke the plugin code and shall be referenced by the plugin descriptor’s “url” attribute. I’ve implemented the config merging you’ve suggested: the structure in configFile gets merged with the structure of “config”, with the data in configFile winning in the case of duplicate key names. BTW, the patch is against ovirt-engine + 0001-WIP-UI-Plugins-PoC-revision-2. Let me know what you think, --Chris